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
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/aspera/log.rb', line 28 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, <<-EOM, nil, __FILE__, __LINE__ + 1) def #{str_level}(message = nil, &block) add(#{int_level}, message, &block) end def #{str_level}? level <= #{int_level} end def #{str_level}! self.level = #{int_level} end EOM end |
Instance Method Details
#format_severity(severity) ⇒ Object
23 24 25 |
# File 'lib/aspera/log.rb', line 23 def format_severity(severity) SEVERITY_LABEL[severity] || 'ANY' end |