Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/sonots/oneline_log_formatter
A ruby logger formatter to output each log in one line forcely
https://github.com/sonots/oneline_log_formatter
Last synced: 3 months ago
JSON representation
A ruby logger formatter to output each log in one line forcely
- Host: GitHub
- URL: https://github.com/sonots/oneline_log_formatter
- Owner: sonots
- License: mit
- Created: 2015-04-23T03:39:08.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2016-08-17T13:46:30.000Z (over 8 years ago)
- Last Synced: 2024-10-13T08:08:25.184Z (3 months ago)
- Language: Ruby
- Homepage:
- Size: 4.88 KB
- Stars: 22
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.txt
Awesome Lists containing this 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
```ruby
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`
```ruby
config.logger.formatter = OnelineLogFormatter.new
```## ChangeLog
See [CHANGELOG.md](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](../../pull/new/master)## Copyright
See [LICENSE.txt](LICENSE.txt) for details.