
Security News
Rspack Introduces Rslint, a TypeScript-First Linter Written in Go
Rspack launches Rslint, a fast TypeScript-first linter built on typescript-go, joining in on the trend of toolchains creating their own linters.
The Ruby Simple Exception Notification (a.k.a Rusen) gem provides a simple way for logging and sending errors in any Ruby application.
Notifications include information about the current request, session, environment. They also provide a backtrace of the exception.
Just add the following line in your Gemfile
gem 'rusen'
The easiest way to use it is with global configuration.
First you configure Rusen
require 'rusen'
Rusen.settings.sender_address = 'oops@example.org'
Rusen.settings.exception_recipients = %w(dev_team@example.org)
Rusen.settings.smtp_settings = {
:address => 'smtp.gmail.com',
:port => 587,
:domain => 'example.org',
:authentication => :plain,
:user_name => 'dev_team@example.org',
:password => 'xxxxxxx',
:enable_starttls_auto => true
}
And then you can start sending notifications:
begin
method.call
rescue Exception => exception
Rusen.notify(exception)
end
This way, if you modify the notifications settings at runtime, every notification sent afterwards will use the new settings.
This method lets you have more control when notifying. You may want for example to send an email when a particular exception occurs and just print to stdout otherwise. To achieve this you can do the following:
@email_notifier = Rusen::Notifier.new(@email_settings)
@stdout_settings = Rusen::Settings.new
@stdout_settings.outputs = [:backtrace]
@stdout_notifier = Rusen::Notifier.new(@stdout_settings)
and then:
begin
method.call
rescue SmallException => exception
@stdout_notifier.notify(exception)
end
Rusen comes with a Rack and rails special (soon to come) middleware for easy usage.
To use Rusen in any Rack application you just have to add the following code somewhere in your app (ex: config/initializers/rusen.rb):
require 'rusen/middleware/rusen_rack'
use Rusen::Middleware::RusenRack,
:outputs => [:io, :email],
:sections => [:backtrace, :request, :session, :environment],
:email_prefix => '[ERROR] ',
:sender_address => 'oops@example.org',
:exception_recipients => %w(dev_team@example.org),
:smtp_settings => {
:address => 'smtp.gmail.com',
:port => 587,
:domain => 'example.org',
:authentication => :plain,
:user_name => 'dev_team@example.org',
:password => 'xxxxxxx',
:enable_starttls_auto => true
}
This will capture any unhandled exception, send an email and write a trace in stdout.
Currently supported outputs are :io, :lo4r, :pony and :mail. More outputs are easy to add so you can customize Rusen to your needs.
Note: :io will only print to stdout for the time being, but there are plans to extend it to anything that Ruby::IO supports.
Pony, lo4r and Mail outputs require additional gems to work.
To use Pony add this to your Gemfile:
gem 'pony'
To use mail, add this to your Gemfile:
gem 'mail'
To use log4r, add this to your Gemfile:
gem 'log4r'
You can choose the output sections simply by setting the appropriate values in the configuration.
Here you can pass a block that will receive the error. If the block returns false, then the error will be notified.
All the email settings are self explanatory, but you can contact hello+rusen@moove-it.com if any of them needs clarification.
If you are running Rusen inside Rails and you have configured smtp_settings for your app Rusen will use that settings by default.
Sample of Log4r configuration file contents:
log4r_config:
loggers:
- name: error_notifications
level: ERROR
trace: false
outputters:
- logfile
- stdoout
outputters:
- type: FileOutputter
name: logfile
filename: 'log/service.log'
- type: StdoutOutputter
name: stdout
Rusen comes with sidekiq integration builtin to use just add this to your sidekiq initializer:
require 'rusen/sidekiq'
You can configure it with the global Rusen configuration, ex:
require 'rusen/sidekiq'
Rusen.settings.sender_address = 'oops@example.org'
Rusen.settings.exception_recipients = %w(dev_team@example.org)
Rusen.settings.smtp_settings = {
:address => 'smtp.gmail.com',
:port => 587,
:domain => 'example.org',
:authentication => :plain,
:user_name => 'dev_team@example.org',
:password => 'xxxxxxx',
:enable_starttls_auto => true
}
Rusen supports versions ~> 2 and ~> 3 of sidekiq.
See the Network View and the CHANGELOG
git checkout -b my-new-feature
)git commit -am 'Added some feature'
)git push origin my-new-feature
)Rusen is released under the MIT License.
FAQs
Unknown package
We found that rusen demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Rspack launches Rslint, a fast TypeScript-first linter built on typescript-go, joining in on the trend of toolchains creating their own linters.
Security News
Hacker Demonstrates How Easy It Is To Steal Data From Popular Password Managers
Security News
Oxlint’s new preview brings type-aware linting powered by typescript-go, combining advanced TypeScript rules with native-speed performance.