SaimonL / CustomLogger

Custom Logger

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Custom Logger

Gem Version Build Status Dependency Status

Custom logger allows you to log you're debug information to an html file so you can view them in much more easier way. All you need to do is include the gem in the Gemfile and then use it directly CustomLogger.

Compatable

CustomLogger is compatible with Ruby 1.9 and above. As for Rails 3.x and up. You should not be using or have Ruby 1.8 installed for obvious reasons.

Installation

Add this line to your application's Gemfile:

group :development, :test do
  [...]
  gem 'customlogger'
  [...]
end

Keep in mind that "[...]" means that there may or may not be other gems there.

And then execute:

$ bundle

Or install it yourself as:

$ gem install customlogger

Usage

Custom Logger is very easy to use. Just use the module 'CustomLogger' anywhere and log the message in a nice friendly colorful html page view. All the logging follows pattern of message input first followed by optional title. Take a look at the examples below.

Example Screenshot

Log error

CustomLogger.error 'This is an error message'
CustomLogger.error('This is an error message', 'Error Title')

Error Screenshot

Log warning

CustomLogger.warning 'This is a warning message'
CustomLogger.warning('This is a warning message', 'Warning Title')

Warning Screenshot

Log debug

CustomLogger.debug 'This is a debug message'
CustomLogger.debug('This is a debug message', 'Debug Title')

Debug Screenshot

Log info

CustomLogger.info 'This is an info message'
CustomLogger.info('This is an info message', 'Info Title')

Info Screenshot

Log raw

Keep in mind that raw means that no formatting is applied so if the output is 1000 characters horizontal without any line break then that is what you will see. Basically it is inside of a 'pre' html tag.

CustomLogger.raw 'This is a raw message'
CustomLogger.raw('This is a raw message', 'Raw Title')

Raw Screenshot

ActiveRecord Support

CustomLogger supports ActiveRecord if you use ActiveRecord. To log ActiveRecord just use raw logger. For an example:

CustomLogger.raw(User.first, 'This is User.first')

ActiveRecord Log

New Line

If you want to add a gap in-between sets of outputs then this is what you are looking for.

CustomLogger.new_line

New Line

Clear All Logs

To clear all logs that are there in the html file

CustomLogger.clear

To auto clear all logs on EACH log

CustomLogger.auto_clear = true

To disable auto clear all logs on EACH log (default)

CustomLogger.auto_clear = false

Log File

You will find the log file in:

log/custom_logger.html

Running Test On Gem (Not Rails App)

bundle exec rake spec

Contributing

  1. Fork it ( https://github.com/SaimonL/CustomLogger/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

About

Custom Logger

License:MIT License


Languages

Language:Ruby 99.8%Language:Shell 0.2%