Module: NewRelic::TelemetrySdk::Logger
Overview
The Logger Singleton object manages the logger for the SDK and is fully configurable by the user.
Any Ruby class that responds to the common methods of the Ruby standard Logger class can be configured for the SDk.
The logger may be configured like this:
Class Method Summary collapse
Instance Method Summary collapse
- #clear_already_logged ⇒ Object
- #log_error(message, exception = nil) ⇒ Object
- #log_once(level, key, *msgs) ⇒ Object
- #logger ⇒ Object
- #logger=(logger) ⇒ Object
Class Method Details
.logger ⇒ Object
43 44 45 |
# File 'lib/newrelic/telemetry_sdk/logger.rb', line 43 def self.logger @logger ||= ::Logger.new(STDOUT) end |
.logger=(logger) ⇒ Object
39 40 41 |
# File 'lib/newrelic/telemetry_sdk/logger.rb', line 39 def self.logger= logger @logger = logger end |
Instance Method Details
#clear_already_logged ⇒ Object
56 57 58 59 60 |
# File 'lib/newrelic/telemetry_sdk/logger.rb', line 56 def clear_already_logged logger_mutex.synchronize do @already_logged = {} end end |
#log_error(message, exception = nil) ⇒ Object
62 63 64 65 |
# File 'lib/newrelic/telemetry_sdk/logger.rb', line 62 def log_error(, exception = nil) logger.error logger.error exception if exception end |
#log_once(level, key, *msgs) ⇒ Object
47 48 49 50 51 52 53 54 |
# File 'lib/newrelic/telemetry_sdk/logger.rb', line 47 def log_once(level, key, *msgs) logger_mutex.synchronize do return if already_logged.include?(key) already_logged[key] = true end logger.send(level, *msgs) end |