Module: MiniLogger
Defined Under Namespace
Classes: Version
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
- #configure(*arguments) ⇒ Object
- #level ⇒ Object
- #level!(nll) ⇒ Object
- #level=(nll) ⇒ Object
- #method_missing(method, *arguments, &block) ⇒ Object
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *arguments, &block) ⇒ Object
113 114 115 116 117 118 119 |
# File 'lib/mini_logger.rb', line 113 def method_missing(method, *arguments, &block) if @logger && [:debug, :info, :warn, :error, :fatal, :debug?, :info?, :warn?, :error?, :fatal?].include?(method) @logger.send(method, *arguments, &block) end end |
Class Method Details
Instance Method Details
#configure(*arguments) ⇒ Object
52 53 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 79 80 81 82 83 84 |
# File 'lib/mini_logger.rb', line 52 def configure(*arguments) configuration = {} case arguments[0] when String configuration.merge!(YAML.load_file(arguments[0])) when Hash 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] unless configuration[:dev] configuration[:level] = configuration[:log_level] unless configuration[:level] raise ArgumentError.new("Invalid log level") unless validate_log_level?(configuration[:level]) configuration[:dev] = case configuration[:dev] when /(STDOUT|stdout)/ then STDOUT when /(STDERR|stderr)/ then STDERR when :stdout then STDOUT when :stderr then STDERR else configuration[:dev] end @logger = ::Logger.new(configuration[:dev]) @logger.level = standarize_log_level(configuration[:level]) self end |
#level ⇒ Object
108 109 110 111 |
# File 'lib/mini_logger.rb', line 108 def level RLLM[@logger.level] if @logger end |
#level!(nll) ⇒ Object
97 98 99 100 101 102 103 104 105 106 |
# File 'lib/mini_logger.rb', line 97 def level!(nll) if @logger raise ArgumentError.new("Invalid log level #{nll.class.name}:'#{nll}'") unless validate_log_level?(nll) @logger.level = standarize_log_level(nll) self end end |
#level=(nll) ⇒ Object
86 87 88 89 90 91 92 93 94 95 |
# File 'lib/mini_logger.rb', line 86 def level=(nll) if @logger raise ArgumentError.new("Invalid log level #{nll.class.name}:'#{nll}'") unless validate_log_level?(nll) @logger.level = standarize_log_level(nll) self end end |