SilentFailCheck
This gem aims to track and log silent failure.
Installation
Add this line to your application's Gemfile:
gem 'silent_fail_check'
And then execute:
$ bundle
Or install it yourself as:
$ gem install silent_fail_check
Usage
SilentFailCheck
is designed to work with ActiveRecord
models. Only ActiveRecord
>= 4.0.0
is supported.
Setup
In order to use SilentFailCheck
you should have a source table, similar to this:
class CreateSilentFailLog < ActiveRecord::Migration
def self.up
create_table :silent_fail_logs do |t|
t.string :message
t.timestamps
end
end
def self.down
drop_table :silent_fail_logs
end
end
Simple model with validations should look like this:
require 'silent_fail_check'
class SilentFailLog < ActiveRecord::Base
validates :message, presence: true
end
You can use SilentFailCheck
like this:
app/models/user.rb
class User < ActiveRecord::Base
validates :connection_time, numericality: true
silent_fail_check :validation, :connection_time
end
In this case, SilentFailCheck
will check and log validation errors happened on :connection_time
Configuration
Default configuration method is:
SilentFailCheck::Logger.configure
If your log model has a different schema, you can redefine columns:
SilentFailCheck::Logger.configure(
model: SilentFailLog, # model class name as source
message: 'MESSAGE_FIELD' # field that contains name
)
Tests
To run the test suite:
bundle install
Then:
bundle exec rspec
Contributing
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request
Licensing
silent_fail_check is licensed under the MIT License. See LICENSE for full license text.