Class: SemanticLogger::Appender::NewRelicLogs
- Inherits:
-
Subscriber
- Object
- Base
- Subscriber
- SemanticLogger::Appender::NewRelicLogs
- Defined in:
- lib/semantic_logger/appender/new_relic_logs.rb
Instance Attribute Summary
Attributes inherited from Subscriber
#application, #environment, #formatter, #host, #logger, #metrics
Attributes inherited from Base
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(formatter: SemanticLogger::Formatters::NewRelicLogs.new, **args, &block) ⇒ NewRelicLogs
constructor
Create Appender.
-
#log(log) ⇒ Object
Send an error notification to New Relic.
Methods inherited from Subscriber
#close, #console_output?, #default_formatter, #flush, #level, #should_log?
Methods inherited from Base
#backtrace, #fast_tag, #level, #level=, #measure, #named_tags, #pop_tags, #push_tags, #should_log?, #silence, #tagged, #tags
Constructor Details
#initialize(formatter: SemanticLogger::Formatters::NewRelicLogs.new, **args, &block) ⇒ NewRelicLogs
Create Appender
Parameters
level: [:trace | :debug | :info | :warn | :error | :fatal]
Override the log level for this appender.
Default: SemanticLogger.default_level
formatter: [Object|Proc]
An instance of a class that implements #call, or a Proc to be used to format
the output from this appender
Default: SemanticLogger::Formatters::NewRelicLogs
filter: [Regexp|Proc]
RegExp: Only include log messages where the class name matches the supplied.
regular expression. All other messages will be ignored.
Proc: Only include log messages where the supplied Proc returns true
The Proc must return true or false.
42 43 44 |
# File 'lib/semantic_logger/appender/new_relic_logs.rb', line 42 def initialize(formatter: SemanticLogger::Formatters::NewRelicLogs.new, **args, &block) super(formatter: formatter, **args, &block) end |
Class Method Details
.log_newrelic(message, level) ⇒ Object
52 53 54 |
# File 'lib/semantic_logger/appender/new_relic_logs.rb', line 52 def self.log_newrelic(, level) ::NewRelic::Agent.agent.log_event_aggregator.record(, level) end |
Instance Method Details
#log(log) ⇒ Object
Send an error notification to New Relic
47 48 49 50 |
# File 'lib/semantic_logger/appender/new_relic_logs.rb', line 47 def log(log) self.class.log_newrelic(formatter.call(log, self).to_json, log.level.to_s.upcase) true end |