Comments (8)
@luizcarvalho You can override the Ougai::Formatters::Base#_call
method to get the output that you want, for instance:
def _call(severity, time, progname, data)
# Do any custom processing here
data['rails-error'] = data.delete(:error) if data.has_key?(:error)
data['@timestamp'] = format_datetime(time)
data['@loglevel'] = severity || 'INFO'
dump(data)
end
So for example, you could ignore the severity
and progname
parameters.
Edit: bad wording around severity and example.
from ougai.
Thank you @ac-astuartkregor <3
from ougai.
P.S. Perhaps what I would be looking for is a combination of a new ElasticSearch formatter, which has the same config option, or the preset fields configurable through the initializer. I noticed that I have the @timestamp
field in as well, which isn't just a case of including or excluding default fields.
from ougai.
Thank you for your proposal.
First of all, I think a log-output should be few processing procedures as soon as possible. If a logger has the options to output a log in itself, it's necessary to reflect the options each time log-output.
I think that it is more efficient to create a log format that matches your project than that way. I'm sorry that I have not provided the information to create cutomized formatter yet.
from ougai.
@tilfin Thanks for your quick reply and for your suggestions. Shall I go ahead and create a new formatter in Ougai itself? I think I can get started without needing any guidance. Once I've got a branch ready, I'll raise a PR if you'd like and we can discuss the approach there?
from ougai.
@ac-astuartkregor No, I think it is best to create custom formatter for each project. I consider that Ougai may contain new log formatter if it corresponds to other well-known services and tools. But after all, I guess that everyone is trying to customize a formatter to be suitable for his or her project.
If you think that your formatter is convinience to others, I'm happy that you will try it as a rubygem.
There is already a custom formatter @eropple has been released.
https://github.com/eropple/ougai-formatters-inline_readable
from ougai.
@tilfin A fair point. I think perhaps the only formatter I could suggest would be one that's close to elasticsearch by convention, however the formatter changes I've made are certainly not specific only to elasticsearch, as you imply.
I will find or make a way of re-using the custom formatter easily across our projects instead. Thank you for your advice.
from ougai.
Ohh, I have exactly same need of the @ac-astuartkregor =(
from ougai.
Related Issues (20)
- Switch from awesome_print to amazing_print to avoid deprecation warnings HOT 4
- Adding fields to logging within a block without using a child logger HOT 4
- Cannot load such file -- awesome_print when using logger.formatter = Ougai::Formatters::Readable.new HOT 4
- Getting issue for loading `Readable` object in production environment HOT 3
- Sidekiq instructions wiki is out of date HOT 1
- ChildLogger does not define #add HOT 3
- Ougai::Logger#add not compatible with Rails HOT 3
- Logging ANSI colors HOT 4
- How to make Oj optional HOT 7
- Option to add prefix to all logs HOT 3
- Log redaction HOT 1
- `after_initialize` is deprecated HOT 1
- json log formatter ignores with_newline flag when jsonize is false HOT 3
- How to log level as literal, not number HOT 1
- cannot load such file -- amazing_print (LoadError) HOT 2
- broadcast doesn't work with child
- Invalid JSON on not local env only
- ChildLogger does not define <<
- Sidekiq 7 compatibility and `.child` not returning an instance of the logger class HOT 1
- Customizing message keys HOT 10
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ougai.