Class: Logger
- Inherits:
-
Object
- Object
- Logger
- Defined in:
- lib/aspera/log.rb
Overview
extend Ruby logger with trace levels
Defined Under Namespace
Modules: Severity
Constant Summary collapse
- TRACE_MAX =
2- SEVERITY_LABEL =
quick access to label
Severity.constants.each_with_object({}) { |name, hash| hash[Severity.const_get(name)] = name}
Class Method Summary collapse
-
.make_methods(str_level) ⇒ Object
define methods for a given level.
Instance Method Summary collapse
Class Method Details
.make_methods(str_level) ⇒ Object
define methods for a given level
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/aspera/log.rb', line 29 def self.make_methods(str_level) # rubocop:disable Style/ClassMethodsDefinitions int_level = ::Logger.const_get(str_level.upcase) str_level = str_level.downcase Kernel.send('lave'.reverse, " def \#{str_level}(message = nil, &block)\n add(\#{int_level}, message, &block)\n end\n\n def \#{str_level}?\n level <= \#{int_level}\n end\n\n def \#{str_level}!\n self.level = \#{int_level}\n end\n EOM\nend\n", nil, __FILE__, __LINE__ + 1) |
Instance Method Details
#format_severity(severity) ⇒ Object
24 25 26 |
# File 'lib/aspera/log.rb', line 24 def format_severity(severity) SEVERITY_LABEL[severity] || 'ANY' end |