Sha256: 3bd1fd331d53fe748a79f7cbab89eac2cec5e857de000f1b294155411c7affc5

Contents?: true

Size: 907 Bytes

Versions: 4

Compression:

Stored size: 907 Bytes

Contents

module Minke
  class Logging
    @@debug = false
    @@ret = "\n"
    
    def self.create_logger(output, verbose = false)
      Logger.new(output).tap do |l|
        l.datetime_format = ''
        l.formatter = proc do |severity, datetime, progname, msg|
          if msg != nil
           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
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
minke-1.15.0 lib/minke/logger.rb
minke-1.14.5 lib/minke/logger.rb
minke-1.14.4 lib/minke/logger.rb
minke-1.14.3 lib/minke/logger.rb