Class: Rollbar::Logger
- Inherits:
-
Logger
- Object
- Logger
- Rollbar::Logger
- Defined in:
- lib/rollbar/logger.rb
Overview
This class provides logger interface that can be used to replace the application logger and send all the log messages to Rollbar
Usage: require ‘rollbar/logger’ logger = Rollbar::Logger.new logger.error(‘Error processing purchase’)
If using Rails, you can extend the Rails logger so messages are logged normally and also to Rollbar:
Rails.logger.extend(ActiveSupport::Logger.broadcast(Rollbar::Logger.new))
Defined Under Namespace
Classes: Error
Instance Method Summary collapse
- #<<(message) ⇒ Object
- #add(severity, message = nil, progname = nil) ⇒ Object
-
#initialize ⇒ Logger
constructor
A new instance of Logger.
-
#rollbar ⇒ Object
Returns a Rollbar::Notifier instance with the current global scope and with a logger writing to /dev/null so we don’t have a infinite loop when Rollbar.configuration.logger is Rails.logger.
Constructor Details
#initialize ⇒ Logger
Returns a new instance of Logger.
20 21 22 23 24 |
# File 'lib/rollbar/logger.rb', line 20 def initialize super(nil) self.level = ERROR end |
Instance Method Details
#<<(message) ⇒ Object
36 37 38 |
# File 'lib/rollbar/logger.rb', line 36 def <<() error() end |
#add(severity, message = nil, progname = nil) ⇒ Object
26 27 28 29 30 31 32 33 34 |
# File 'lib/rollbar/logger.rb', line 26 def add(severity, = nil, progname = nil) return true if severity < @level ||= block_given? ? yield : progname return true if blank?() .log((severity), ) end |
#rollbar ⇒ Object
Returns a Rollbar::Notifier instance with the current global scope and with a logger writing to /dev/null so we don’t have a infinite loop when Rollbar.configuration.logger is Rails.logger.
43 44 45 46 47 48 |
# File 'lib/rollbar/logger.rb', line 43 def notifier = Rollbar.scope notifier.configuration.logger = ::Logger.new('/dev/null') notifier end |