Class: ExtendedLogger
- Inherits:
-
Logger
- Object
- Logger
- ExtendedLogger
- Defined in:
- lib/extended_logger/factory.rb,
lib/extended_logger/formatter.rb,
lib/extended_logger/extended_logger.rb
Defined Under Namespace
Class Method Summary collapse
- .configure(receiver, attribute_name = nil) ⇒ Object
- .get(receiver) ⇒ Object
- .instance ⇒ Object
- .level?(level) ⇒ Boolean
- .levels ⇒ Object
Instance Method Summary collapse
Class Method Details
.configure(receiver, attribute_name = nil) ⇒ Object
2 3 4 5 6 7 8 9 |
# File 'lib/extended_logger/extended_logger.rb', line 2 def self.configure receiver, attribute_name=nil attribute_name ||= 'logger'.freeze setter = "#{attribute_name}=".freeze logger = get receiver receiver.public_send setter, logger end |
.get(receiver) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/extended_logger/extended_logger.rb', line 11 def self.get receiver receiver_name = if receiver.is_a? Module receiver.name else receiver.class.name end logger = Factory.() logger.progname = "(#{receiver_name})" logger end |
.instance ⇒ Object
25 26 27 |
# File 'lib/extended_logger/extended_logger.rb', line 25 def self.instance @instance ||= Factory.() end |
.level?(level) ⇒ Boolean
48 49 50 |
# File 'lib/extended_logger/extended_logger.rb', line 48 def self.level? level levels.key? level end |
.levels ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/extended_logger/extended_logger.rb', line 29 def self.levels @levels ||= { -7 => 'OBSOLETE'.freeze, -6 => 'DATA'.freeze, -5 => 'TRACE'.freeze, -4 => 'DEBUG'.freeze, -3 => 'OPT_DATA'.freeze, -2 => 'OPT_TRACE'.freeze, -1 => 'OPT_DEBUG'.freeze, 0 => 'INFO'.freeze, 1 => 'PASS'.freeze, 2 => 'FAIL'.freeze, 3 => 'FOCUS'.freeze, 4 => 'WARN'.freeze, 5 => 'ERROR'.freeze, 6 => 'FATAL'.freeze, } end |
Instance Method Details
#format_severity(severity) ⇒ Object
52 53 54 55 56 57 58 |
# File 'lib/extended_logger/extended_logger.rb', line 52 def format_severity severity unless self.class.level? severity Kernel.warn "(extended-logger) Unknown log severity level #{severity.inspect}" end self.class.levels.fetch severity, 'ANY'.freeze end |
#io ⇒ Object
60 61 62 63 |
# File 'lib/extended_logger/extended_logger.rb', line 60 def io return unless @logdev @logdev.dev end |
#unknown(*arguments, &block) ⇒ Object
65 66 67 |
# File 'lib/extended_logger/extended_logger.rb', line 65 def unknown *arguments, &block add 7, *arguments, &block end |