https://github.com/umbrellio/lamian
Lamian is an extension to exception notification system, which helps to add logs of current request/job to the exception report
https://github.com/umbrellio/lamian
Last synced: about 1 year ago
JSON representation
Lamian is an extension to exception notification system, which helps to add logs of current request/job to the exception report
- Host: GitHub
- URL: https://github.com/umbrellio/lamian
- Owner: umbrellio
- License: mit
- Created: 2016-08-13T06:28:32.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2024-12-12T11:08:18.000Z (over 1 year ago)
- Last Synced: 2025-03-28T19:13:09.593Z (about 1 year ago)
- Language: Ruby
- Homepage:
- Size: 82 KB
- Stars: 8
- Watchers: 3
- Forks: 2
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Changelog: Changelog.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# Lamian
[](https://github.com/umbrellio/lamian/actions) [](https://coveralls.io/github/umbrellio/lamian?branch=master) [](https://badge.fury.io/rb/lamian)
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](https://github.com/smartinez87/exception_notification/blob/master/README.md))
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.
```ruby
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:
```ruby
config.server_middleware do |chain|
chain.prepend(Lamian::SidekiqSentryMiddleware)
end
```
### Usage with SemanticLogger
You should add Lamian appender to the SematicLogger appenders like this:
```ruby
SemanticLogger.add_appender(appender: Lamian::SemanticLoggerAppender.new)
```
### Patching Sentry Scope
If you want to send events asynchronously you need to patch `Sentry::Scope`.
```ruby
# Somewhere in a initializer.
Sentry::Scope.prepend(Lamian::SentryScopePatch)
```
## Raven (deprecated)
### Usage
Add this line to your Sentry initializer:
```ruby
Raven::Context.prepend(Lamian::RavenContextExtension)
```
### Usage with Sidekiq
You should add Lamian middleware to the Sidekiq initializer like this:
```ruby
config.server_middleware do |chain|
chain.prepend(Lamian::SidekiqRavenMiddleware)
end
```
## Contribution
Feel free to contribute by making PRs and Issues on [GitHub](https://github.com/JelF/lamian)
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