class MiniLogger
Constants
- DEBUG
- ERROR
- FATAL
- INFO
- LLM
- RLLM
- WARN
Public Class Methods
configure(*arguments)
click to toggle source
# 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
new(options)
click to toggle source
# File lib/mini_logger.rb, line 80 def initialize(options) @logger = ::Logger.new(options[:dev]) @logger.level = MiniLogger.standarize_log_level(options[:level]) self end
validate_log_level?(level)
click to toggle source
# File lib/mini_logger.rb, line 44 def self.validate_log_level?(level) case level when String then LLM.has_key?(level.downcase.to_sym) when Symbol then LLM.has_key?(level.to_s.downcase.to_sym) else false end end
Private Class Methods
standarize_log_level(level)
click to toggle source
# File lib/mini_logger.rb, line 34 def self.standarize_log_level(level) case level when String then LLM[level.downcase.to_sym] when Symbol then LLM[level.to_s.downcase.to_sym] end end
Public Instance Methods
level()
click to toggle source
# File lib/mini_logger.rb, line 96 def level RLLM[@logger.level] end
level=(level)
click to toggle source
# 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