0.01
Low commit activity in last 3 years
No release in over a year
This library provides basic functionality for recording error logs during project execution.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.4.4

Runtime

>= 6.1.6.1
 Project Readme

Exception Logger for Rails

Store the error logs of your rails application directly in the application's database. Just a quick way to monitor error logs without the need for additional tools.

Install

Inside your Gemfile:

gem 'exception_logger'

and then run:

bundle install

Inside your ApplicationController:

include ExceptionLogger::ExceptionLoggable # load the module
rescue_from Exception, with: :log_exception_handler # tells rails to forward the 'Exception' (you can change the type) to the handler of the module

Inside your config/routes.rb

mount ExceptionLogger::Engine => "/exception_logger"

Database Setup

Use

rails exception_logger:install:migrations

This will create a database migration inside db/migrations

TIMESTAMP_create_exception_logger_logged_exceptions.exception_logger.rb

Then

rails db:migrate

Authentication

If you want, and believe me you want that, you can add the following lines in config/initializers/exception_logger.rb to enable Authentication:

Rails.application.config.after_initialize do
  ExceptionLogger::LoggedExceptionsController.class_eval do
    before_filter :authorize

    protected

    def authorize
      redirect_to main_app.admin_login_path unless admin_logged?
    end

    def admin_logged?
      session[:admin_user_id].present?
    end
  end
end

Usage

To localize the interface:

en:
  exception_logger:
    logged_exceptions:
      index:
        title: Logged Exceptions
        filters: Filters
        latest_exceptions: Latest Exceptions
        exception: Exception
        controller_action: Controller / Action
        dates: Dates
        today: Today
        last_few_days: Last few days
        last_7_days: Last 7 days
        last_30_days: Last 30 days
      show:
        title: Logged Exception

To log extra data, in your ApplicationController:

self.exception_data = Proc.new { |controller| 'Extra exception infomation here!' }

or

self.exception_data = :extra_exception_data

def extra_exception_data
  'Extra exception infomation here!'
end

Gem Dependencies

Please check if all those requirements are satisfied on your environment.

  • will_paginate >= 3.3.1 (used for pagination)
  • rails >= 6.1

License

MIT License. See LICENSE for details.