Sha256: 68c7b001cfa265ecca4df337700e4bd77da420fdb4cbe2eae29d560fafbbb32d

Contents?: true

Size: 843 Bytes

Versions: 15

Compression:

Stored size: 843 Bytes

Contents

module Minke
  class Logging
    @@debug = false
    @@ret = "\n"
    
    def self.create_logger verbose = false
      Logger.new(STDOUT).tap do |l|
        l.datetime_format = ''
        l.formatter = proc do |severity, datetime, progname, msg|
          case severity
          when 'ERROR'
            s = "#{@@ret if @@debug}#{'ERROR'.colorize(:red)}: #{msg.chomp('')}\n"
            @@debug = false
            s
          when 'INFO'
            s = "#{@@ret if @@debug}#{'INFO'.colorize(:green)}: #{msg.chomp('')}\n"
            @@debug = false
            s
          when 'DEBUG'
            if verbose == true
              "#{'DEBUG'.colorize(:yellow)}: #{msg.chomp('')}\n"
            else
              @@debug = true
              "#{'.'.colorize(:yellow)}"
            end
          end
        end
      end
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
minke-1.14.2 lib/minke/logger.rb
minke-1.14.1 lib/minke/logger.rb
minke-1.14.0 lib/minke/logger.rb
minke-1.13.20 lib/minke/logger.rb
minke-1.13.19 lib/minke/logger.rb
minke-1.13.18 lib/minke/logger.rb
minke-1.13.16 lib/minke/logger.rb
minke-1.13.15 lib/minke/logger.rb
minke-1.13.14 lib/minke/logger.rb
minke-1.13.13 lib/minke/logger.rb
minke-1.13.12 lib/minke/logger.rb
minke-1.13.11 lib/minke/logger.rb
minke-1.13.10 lib/minke/logger.rb
minke-1.13.9 lib/minke/logger.rb
minke-1.13.8 lib/minke/logger.rb