Giter Site home page Giter Site logo

Comments (8)

ac-astuartkregor avatar ac-astuartkregor commented on August 25, 2024 1

@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.

luizcarvalho avatar luizcarvalho commented on August 25, 2024 1

Thank you @ac-astuartkregor <3

from ougai.

ac-astuartkregor avatar ac-astuartkregor commented on August 25, 2024

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.

tilfin avatar tilfin commented on August 25, 2024

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.

ac-astuartkregor avatar ac-astuartkregor commented on August 25, 2024

@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.

tilfin avatar tilfin commented on August 25, 2024

@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.

ac-astuartkregor avatar ac-astuartkregor commented on August 25, 2024

@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.

luizcarvalho avatar luizcarvalho commented on August 25, 2024

Ohh, I have exactly same need of the @ac-astuartkregor =(

from ougai.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.