Class: RailsObservatory::LogCollector
- Inherits:
-
Logger
- Object
- Logger
- RailsObservatory::LogCollector
- Defined in:
- lib/rails_observatory/log_collector.rb
Constant Summary collapse
- KEY =
:observatory_logs
Class Method Summary collapse
Instance Method Summary collapse
- #<<(message) ⇒ Object
- #add(severity, message = nil, progname = nil, &block) ⇒ Object (also: #log)
-
#initialize(*args, **kwargs) ⇒ LogCollector
constructor
A new instance of LogCollector.
Constructor Details
#initialize(*args, **kwargs) ⇒ LogCollector
Returns a new instance of LogCollector.
6 7 8 9 |
# File 'lib/rails_observatory/log_collector.rb', line 6 def initialize(*args, **kwargs) _, *rest = args super(nil, *rest, **kwargs) end |
Class Method Details
Instance Method Details
#<<(message) ⇒ Object
39 40 41 42 43 |
# File 'lib/rails_observatory/log_collector.rb', line 39 def <<() if (logs = ActiveSupport::IsolatedExecutionState[KEY]) logs << { severity: UNKNOWN, message:, progname: nil, time: Time.now.to_f } end end |
#add(severity, message = nil, progname = nil, &block) ⇒ Object Also known as: log
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/rails_observatory/log_collector.rb', line 20 def add(severity, = nil, progname = nil, &block) if (logs = ActiveSupport::IsolatedExecutionState[KEY]) severity ||= UNKNOWN return true if severity < level progname = @progname if progname.nil? if .nil? if block_given? = yield else = progname progname = @progname end end logs << { severity:, message:, progname:, time: Time.now.to_f } end end |