Sha256: 10e16a620b3ed52e64d4f1ac7bdb25f698c3a31184a81af049f80e90d3a370d2

Contents?: true

Size: 1.54 KB

Versions: 9

Compression:

Stored size: 1.54 KB

Contents

########    #######    ########    #######    ########    ########
##     / / / /    License    \ \ \ \
##    Copyleft culture, Copyright (C) is prohibited here
##    This work is licensed under a CC BY-SA 4.0
##    Creative Commons Attribution-ShareAlike 4.0 License
##    Refer to the http://creativecommons.org/licenses/by-sa/4.0/
########    #######    ########    #######    ########    ########
##    / / / /    Code Climate    \ \ \ \
##    Language = ruby
##    Indent = space;    2 chars;
########    #######    ########    #######    ########    ########

module ArchestryLookup
  def self.logger
    @logger ||= Log.new('info')
  end

  class Log
    def initialize(debug_level)
      @logger ||= Logger.new(STDERR)
      @logger.datetime_format = "sec: %S.%6N"
      @logger.formatter = proc do |_severity, _datetime, _progname, msg|
        "#{msg}\n"
      end

      @debug_level = debug_level
    end

    def catch(message)
      @logger.debug "\033[33m#{message}\033[0m" if [:debug].include? @debug_level.to_sym
    end

    def debug(message)
      @logger.debug "\033[32m#{message}\033[0m" if [:debug].include? @debug_level.to_sym
    end

    def info(message)
      @logger.info "\033[36m#{message}\033[0m"  if [:info, :debug].include? @debug_level.to_sym
    end

    def warn(message)
      @logger.warn "\033[35m#{message}\033[0m"  if [:warn, :info, :debug].include? @debug_level.to_sym
    end

    def error(message)
      @logger.error "\033[31m#{message}\033[0m" if [:error, :warn, :info, :debug].include? @debug_level.to_sym
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
archestry_lookup-0.0.19 lib/tooling/log.rb
archestry_lookup-0.0.18 lib/tooling/log.rb
archestry_lookup-0.0.17 lib/tooling/log.rb
archestry_lookup-0.0.16 lib/tooling/log.rb
archestry_lookup-0.0.15 lib/tooling/log.rb
archestry_lookup-0.0.14 lib/tooling/log.rb
archestry_lookup-0.0.13 lib/tooling/log.rb
archestry_lookup-0.0.12 lib/tooling/log.rb
archestry_lookup-0.0.11 lib/tooling/log.rb