Project

oxy_logger

0.0
No commit activity in last 3 years
No release in over 3 years
This is a simple logger that is easy to use and can be configured as you want.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.15
~> 10.0
~> 3.0
~> 0.9.9
 Project Readme

OxyLogger

Welcome to our Rails logger gem!

This is a simple logger that is easy to use and can be configured as you want.

Installation

Add this line to your application's Gemfile:

  gem 'oxy_logger', '~> 0.3.0'

Then run:

$ bundle install

Usage

To include gem tasks inside your rails app. Add this code to rails Rakefile:

  spec = Gem::Specification.find_by_name 'oxy_logger'
  load "#{spec.gem_dir}/lib/tasks/logger_install.rake"

Then run the rake task. This command will create a configuration file in your application and run the migration to update your database.

$ rake oxy:install

Controller or Model logging

In order to log the controller methods, add in app/controllers/application_controller.rb Do the same code for the Model, if you need to log it app/models/application_record.rb

  extend OxyLogger::Sys
  include OxyLogger::Helper

And at the end, specify what methods you want to use for logging. IMPORTANT! The method log_it must be at the end of the logged methods.

  logg_it [ :index, :show, :new, :edit, :create, :update, :destroy ] # Select any of the available methods

Very simple isn't?

Configuration

When you launched the rake task a configuration file was copied into your project, which you can find at /config/initializers/logger_init.rb

OxyLogger.configure do |config|
  # Save logs locally to a file or database
  config.save_to = "file"  # or config.save_to = "db"

If you want to log to a file, you can specify the path to it. If this file does not exist, the OxyLogger will create it.

  #  config.files_path = Rails.root + "/log/logged_data" # the same things in example 
  config.files_path = Rails.root.join('log', 'logged_data')

You can choose which parameters you want to record. Unnecessary parameter just comment out or delete.

  config.logget_fields = %i[
    date_time         # called time
    class_name        # class in which was called
    method_name       # method in which was called
    result            # return result
    params            # parameters
  ]

Contributing

We will be very happy if our product interests you and you will have an irresistible desire to help us with its development.

https://github.com/[USERNAME]/oxy_logger.

License

The gem is available as open source under the terms of the MIT License.