Class: Rack::Timeout::StateChangeLoggingObserver
- Inherits:
-
Object
- Object
- Rack::Timeout::StateChangeLoggingObserver
- Defined in:
- lib/rack/timeout/logging-observer.rb
Constant Summary collapse
- STATE_LOG_LEVEL =
{ :expired => :error, :ready => :info, :active => :debug, :timed_out => :error, :completed => :info, }
- SIMPLE_FORMATTER =
->(severity, , progname, msg) { "#{msg} at=#{severity.downcase}\n" }
Instance Attribute Summary collapse
-
#logger ⇒ Object
writeonly
Sets the attribute logger.
Class Method Summary collapse
Instance Method Summary collapse
-
#callback ⇒ Object
returns the Proc to be used as the observer callback block.
-
#initialize ⇒ StateChangeLoggingObserver
constructor
A new instance of StateChangeLoggingObserver.
Constructor Details
#initialize ⇒ StateChangeLoggingObserver
Returns a new instance of StateChangeLoggingObserver.
11 12 13 |
# File 'lib/rack/timeout/logging-observer.rb', line 11 def initialize @logger = nil end |
Instance Attribute Details
#logger=(value) ⇒ Object
Sets the attribute logger
29 30 31 |
# File 'lib/rack/timeout/logging-observer.rb', line 29 def logger=(value) @logger = value end |
Class Method Details
.mk_logger(device, level = ::Logger::INFO) ⇒ Object
21 22 23 24 25 26 |
# File 'lib/rack/timeout/logging-observer.rb', line 21 def self.mk_logger(device, level = ::Logger::INFO) ::Logger.new(device).tap do |logger| logger.level = level logger.formatter = SIMPLE_FORMATTER end end |
Instance Method Details
#callback ⇒ Object
returns the Proc to be used as the observer callback block
16 17 18 |
# File 'lib/rack/timeout/logging-observer.rb', line 16 def callback method(:log_state_change) end |