lib/semantic_logger/appender/sentry.rb in semantic_logger-4.2.2 vs lib/semantic_logger/appender/sentry.rb in semantic_logger-4.3.0
- old
+ new
@@ -35,27 +35,29 @@
# Default: SemanticLogger.host
#
# application: [String]
# Name of this application to appear in log messages.
# Default: SemanticLogger.application
- def initialize(level: :error, formatter: nil, filter: nil, application: nil, host: nil, &block)
+ 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(level: level, formatter: formatter, filter: filter, application: application, host: host, &block)
+ super(level: level, **args, &block)
end
# Send an error notification to sentry
def log(log)
# Ignore logs coming from Raven itself
return false if log.name == 'Raven'
context = formatter.call(log, self)
- attrs = {
+ user = context.delete(:user)
+ tags = context.delete(:tags)
+ attrs = {
level: context.delete(:level),
- user: context.delete(:user),
- tags: context.delete(:tags),
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