Module: LunaPark::Notifiers::TaggedLog
- Extended by:
- Forwardable
- Includes:
- Extensions::SeverityLevels
- Defined in:
- lib/luna_park/notifiers/tagged_log.rb,
lib/luna_park/notifiers/tagged_log/options.rb,
lib/luna_park/notifiers/tagged_log/tagged_formatter.rb
Defined Under Namespace
Modules: Formatter Classes: Options, TaggedFormatter
Constant Summary
Constants included from Extensions::SeverityLevels
Extensions::SeverityLevels::LEVELS
Instance Attribute Summary collapse
-
#output ⇒ Object
Returns the value of attribute output.
Class Method Summary collapse
Instance Method Summary collapse
Methods included from Extensions::SeverityLevels
#debug, #error, #fatal, #info, #min_lvl, #min_lvl=, #unknown, #warning
Instance Attribute Details
#output ⇒ Object
Returns the value of attribute output.
27 28 29 |
# File 'lib/luna_park/notifiers/tagged_log.rb', line 27 def output @output end |
Class Method Details
.new(output = $stdout, **options) ⇒ Object
91 92 93 94 95 96 97 98 99 100 101 102 |
# File 'lib/luna_park/notifiers/tagged_log.rb', line 91 def self.new(output = $stdout, **) config = LunaPark::Notifiers::TaggedLog::Options.wrap() logger = Logger.new(output) logger.formatter = LunaPark::Notifiers::TaggedLog::TaggedFormatter.new logger.formatter.config = config logger.formatter.extend(Formatter) logger.extend(self) logger.output = output logger.min_lvl = config.min_lvl logger end |
Instance Method Details
#post(msg, lvl: :error, **details) ⇒ Object
78 79 80 81 82 |
# File 'lib/luna_park/notifiers/tagged_log.rb', line 78 def post(msg, lvl: :error, **details) severity = severity(lvl) = { original_msg: msg, details: details } add severity, end |
#severity(lvl) ⇒ Object
84 85 86 87 88 89 |
# File 'lib/luna_park/notifiers/tagged_log.rb', line 84 def severity(lvl) severity = SEVERITY_LEVELS[lvl] raise ArgumentError, "Unknown level #{lvl}" if severity.nil? severity end |
#tagged(*tags) ⇒ Object
66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/luna_park/notifiers/tagged_log.rb', line 66 def tagged(*) if block_given? formatter.tagged(*) { yield self } else logger = LunaPark::Notifiers::TaggedLog.new( output, **formatter.config.to_h ) logger.(*formatter., *) logger end end |