Skip to content

Latest commit

 

History

History
101 lines (67 loc) · 3.09 KB

README.md

File metadata and controls

101 lines (67 loc) · 3.09 KB

Lamian

Actions Status Coverage Status Gem Version

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

Usage with ExceptionNotification

  1. Add gem 'lamian' into your Gemfile
  2. Extend Rails.logger and any other loggers you want to mirror by Lamian::LoggerExtension: Lamian.extend_logger(logger)
  3. Add 'request_log' section inside your ExceptionNotification.configure (see ExceptionNotification README)
  4. ExceptionNotification's messages would have 'Request Log' section

Extended Usage

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.

Sentry (sentry-ruby)

Usage

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)

Usage with Sidekiq

You should add Lamian middleware to the Sidekiq initializer like this:

config.server_middleware do |chain|
  chain.prepend(Lamian::SidekiqSentryMiddleware)
end

Usage with SemanticLogger

You should add Lamian appender to the SematicLogger appenders like this:

SemanticLogger.add_appender(appender: Lamian::SemanticLoggerAppender.new)

Patching Sentry Scope

If you want to send events asynchronously you need to patch Sentry::Scope.

# Somewhere in a initializer.

Sentry::Scope.prepend(Lamian::SentryScopePatch)

Raven (deprecated)

Usage

Add this line to your Sentry initializer:

Raven::Context.prepend(Lamian::RavenContextExtension)

Usage with Sidekiq

You should add Lamian middleware to the Sidekiq initializer like this:

config.server_middleware do |chain|
  chain.prepend(Lamian::SidekiqRavenMiddleware)
end

Contribution

Feel free to contribute by making PRs and Issues on GitHub You also can contact me using my email [email protected]

TODO

  • It probably should be separated to lamian and lamian-rails gems. Rails dependency is never cool