class SemanticLogger::Appender::Sentry
def default_formatter
def default_formatter SemanticLogger::Formatters::Raw.new end
def initialize(level: :error, **args, &block)
Name of this application to appear in log messages.
application: [String]
Default: SemanticLogger.host
Name of this host to appear in log messages.
host: [String]
The Proc must return true or false.
Proc: Only include log messages where the supplied Proc returns true
regular expression. All other messages will be ignored.
RegExp: Only include log messages where the class name matches the supplied.
filter: [Regexp|Proc]
Default: Use the built-in formatter (See: #call)
the output from this appender
An instance of a class that implements #call, or a Proc to be used to format
formatter: [Object|Proc|Symbol|Hash]
Default: :error
Override the log level for this appender.
level: [:trace | :debug | :info | :warn | :error | :fatal]
Parameters
Create Appender
def initialize(level: :error, **args, &block) # Replace the Sentry Raven logger so that we can identify its log messages and not forward them to Sentry Raven.configure { |config| config.logger = SemanticLogger[Raven] } super end
def log(log)
def log(log) # Ignore logs coming from Raven itself return false if log.name == "Raven" context = formatter.call(log, self) user = context.delete(:user) tags = context.delete(:tags) attrs = { level: context.delete(:level), extra: context } attrs[:user] = user if user attrs[:tags] = tags if tags if log.exception context.delete(:exception) Raven.capture_exception(log.exception, attrs) else attrs[:extra][:backtrace] = log.backtrace if log.backtrace Raven.capture_message(context[:message], attrs) end true end