Class: NyplLogFormatter

Inherits:
Logger
  • Object
show all
Includes:
NyplLogFormatterVersion
Defined in:
lib/nypl_log_formatter.rb

Constant Summary

Constants included from NyplLogFormatterVersion

NyplLogFormatterVersion::VERSION

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ NyplLogFormatter

Returns a new instance of NyplLogFormatter.



9
10
11
12
13
14
# File 'lib/nypl_log_formatter.rb', line 9

def initialize(*args)
  super(*args)
  # This has to happen _after_ call to super, otherwise ::Logger will set the formatter
  set_formatter
  allow_arbitrary_keys
end

Instance Method Details

#silence(temporary_level = NyplLogFormatter::ERROR) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
# File 'lib/nypl_log_formatter.rb', line 16

def silence(temporary_level = NyplLogFormatter::ERROR)
  old_local_level = self.level
  begin
    self.level = temporary_level
    yield self
  rescue Exception
    self.level = old_local_level
  ensure
    self.level = old_local_level
  end
end