Sha256: bb97f347bc11f31ae9ea0987d72636a67c488b8da5033b44ac9e7294e9de04e5

Contents?: true

Size: 703 Bytes

Versions: 5

Compression:

Stored size: 703 Bytes

Contents

# frozen_string_literal: true

require "pakyow/support/cli/style"

module Pakyow
  class Logger
    # Helpers for colorizing log messages.
    #
    module Colorizer
      # Colorizes message based on level.
      #
      def self.colorize(message, level)
        if color = color(level)
          Support::CLI.style.public_send(color, message)
        else
          message
        end
      end

      LEVEL_COLORS = {
        internal: :magenta,
        debug: :cyan,
        info: :green,
        warn: :yellow,
        error: :red,
        fatal: :red
      }.freeze

      # Returns a color for a level.
      #
      def self.color(level)
        LEVEL_COLORS[level]
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
pakyow-core-1.0.6 lib/pakyow/logger/colorizer.rb
pakyow-core-1.0.5 lib/pakyow/logger/colorizer.rb
pakyow-core-1.0.4 lib/pakyow/logger/colorizer.rb
pakyow-core-1.0.3 lib/pakyow/logger/colorizer.rb
pakyow-core-1.0.2 lib/pakyow/logger/colorizer.rb