Class: MiniLogger
Constant Summary collapse
- DEBUG =
:debug
- INFO =
:info
- WARN =
:warn
- ERROR =
:error
- FATAL =
:fatal
- LLM =
{ :debug =>::Logger::DEBUG, :info =>::Logger::INFO, :warn =>::Logger::WARN, :error =>::Logger::ERROR, :fatal =>::Logger::FATAL }
- RLLM =
{ ::Logger::DEBUG => DEBUG, ::Logger::INFO => INFO, ::Logger::WARN => WARN, ::Logger::ERROR => ERROR, ::Logger::FATAL => FATAL }
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(options) ⇒ MiniLogger
constructor
A new instance of MiniLogger.
- #level ⇒ Object
- #level=(level) ⇒ Object
Constructor Details
#initialize(options) ⇒ MiniLogger
Returns a new instance of MiniLogger.
80 81 82 83 84 85 86 |
# File 'lib/mini_logger.rb', line 80 def initialize() @logger = ::Logger.new([:dev]) @logger.level = MiniLogger.standarize_log_level([:level]) self end |
Class Method Details
.configure(*arguments) ⇒ Object
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/mini_logger.rb', line 54 def self.configure(*arguments) configuration = Hash.new case arguments[0] when String then configuration.merge!(YAML.load_file(arguments[0])) when Hash then configuration.merge!(arguments[0]) else configuration = { :dev=>STDERR, :level=>:debug } end configuration = { :log_channel=>STDERR, :log_level=>:info }.merge(configuration) configuration[:dev] ||= configuration[:log_channel] configuration[:level] ||= configuration[:log_level] raise ArgumentError.new("Invalid log level") unless validate_log_level?(configuration[:level]) configuration[:dev] = case configuration[:dev].to_s.downcase when /stdout/ then STDOUT when /stderr/ then STDERR else configuration[:dev] end self.new(configuration) end |
Instance Method Details
#level ⇒ Object
96 97 98 99 |
# File 'lib/mini_logger.rb', line 96 def level RLLM[@logger.level] end |
#level=(level) ⇒ Object
88 89 90 91 92 93 94 |
# File 'lib/mini_logger.rb', line 88 def level=(level) raise ArgumentError.new("Invalid log level #{level.class.name}:'#{level}'") unless MiniLogger.validate_log_level?(level) @logger.level = MiniLogger.standarize_log_level(level) self end |