No commit activity in last 3 years
No release in over 3 years
A logger formatter to output each log in one line forcely
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies
 Project Readme

OnelineLogFormatter

A logger formatter to output each log with in line forcely

What is this for?

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.

Installation

Add this line to your application's Gemfile:

gem 'oneline_log_formatter'

And then execute:

$ bundle

How to use

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.

Rails

Configure at config/application.rb

config.logger.formatter = OnelineLogFormatter.new

ChangeLog

See CHANGELOG.md for details.

Contributing

  1. Fork it
  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 new Pull Request

Copyright

See LICENSE.txt for details.