Lamian is an in-memory logger, which content could be released for error messages.
It is designed to work in pair with exception_notification
gem inside rails
aplications
- Add
gem 'lamian'
into your Gemfile - Extend
Rails.logger
and any other loggers you want to mirror byLamian::LoggerExtension
:Lamian.extend_logger(logger)
- Add 'request_log' section inside your
ExceptionNotification.configure
(see ExceptionNotification README) - ExceptionNotification's messages would have 'Request Log' section
Add a 'request_log' section into ExceptionNotification's background section.
Add Lamian.run { }
around code with logs you want to collect. Note, that
logs would be accessible only inside this section and removed after section end.
It automatically redefines Sentry.configuration.before_send
callback
if Sentry initialization is completed. If before_send
is already defined
it wraps custom callback.
If you work with rails the Lamian::Engine
will be automatically initialized, that additionally
adds Lamian::Middleware
in the first position in your Rails Application middleware stack.
If you need to manually configure the middleware stack use `Lamian.config.middleware_autoset=false.
Lamian.configure do |config|
config.middleware_autoset = false
end
Rails.configuration.middleware.use_after(YourSignificantMiddlewareInStack, Lamian::Middleware)
You should add Lamian middleware to the Sidekiq initializer like this:
config.server_middleware do |chain|
chain.prepend(Lamian::SidekiqSentryMiddleware)
end
You should add Lamian appender to the SematicLogger appenders like this:
SemanticLogger.add_appender(appender: Lamian::SemanticLoggerAppender.new)
If you want to send events asynchronously you need to patch Sentry::Scope
.
# Somewhere in a initializer.
Sentry::Scope.prepend(Lamian::SentryScopePatch)
Add this line to your Sentry initializer:
Raven::Context.prepend(Lamian::RavenContextExtension)
You should add Lamian middleware to the Sidekiq initializer like this:
config.server_middleware do |chain|
chain.prepend(Lamian::SidekiqRavenMiddleware)
end
Feel free to contribute by making PRs and Issues on GitHub You also can contact me using my email begdory4+lamian@gmail.com
- It probably should be separated to
lamian
andlamian-rails
gems. Rails dependency is never cool