Project

lamian

0.01
Low commit activity in last 3 years
A long-lived project that still receives updates
Add logs to your error messages, using exception_notifier or smth like it
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies
 Project Readme

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.

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 begdory4+lamian@gmail.com

TODO

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