A logger formatter to output each log with in line forcely
Rails default log formatter outputs backtrace in multiple lines, and it makes difficult to parse the log.
This log formatter replaces sthe line feed characters \n
with \\n
so that log messages will be in one line.
Add this line to your application's Gemfile:
gem 'oneline_log_formatter'
And then execute:
$ bundle
require 'logger'
require 'oneline_log_formatter'
logger = Logger.new(STDOUT)
logger.formatter = OnelineLogFormatter.new
logger.info("foo\nbar")
which outputs logs like
20150423T00:00:00+09:00 [INFO] foo\nbar
Note that the line feed character is converted into \n
.
Configure at config/application.rb
config.logger.formatter = OnelineLogFormatter.new
See CHANGELOG.md for details.
- 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
See LICENSE.txt for details.