Custom Logger
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.
Log error
CustomLogger.error 'This is an error message'
CustomLogger.error('This is an error message', 'Error Title')
Log warning
CustomLogger.warning 'This is a warning message'
CustomLogger.warning('This is a warning message', 'Warning Title')
Log debug
CustomLogger.debug 'This is a debug message'
CustomLogger.debug('This is a debug message', 'Debug Title')
Log info
CustomLogger.info 'This is an info message'
CustomLogger.info('This is an info message', 'Info Title')
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')
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')
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
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
- Fork it ( https://github.com/SaimonL/CustomLogger/fork )
- 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 a new Pull Request