Giter Site home page Giter Site logo

Accessing errors and fields in hooks about zerolog HOT 6 CLOSED

rs avatar rs commented on July 28, 2024
Accessing errors and fields in hooks

from zerolog.

Comments (6)

asdine avatar asdine commented on July 28, 2024 1

@Dragomir-Ivanov Sure, here is a gist https://gist.github.com/asdine/f821abe6189a04250ae61b77a3048bd9

Hope that helps

from zerolog.

Dragomir-Ivanov avatar Dragomir-Ivanov commented on July 28, 2024 1

Thanks a ton, mate :)

from zerolog.

asdine avatar asdine commented on July 28, 2024

For now, i'm using an io.Pipe and passing an io.MultiWriter(os.Stderr, pw) to zerolog, and using a json.Decoder so i can extract the json from the output and use the fields i need.
It works fine (probably not the fastest way though) but i'm wondering if there is a simpler way.

from zerolog.

rs avatar rs commented on July 28, 2024

zerolog doesnโ€™t store the error in an intermediary form; errors are serialized on the fly for best performance. The only way to access the fields in the hooks is to deserialize. Check the journald writer for an example.

from zerolog.

asdine avatar asdine commented on July 28, 2024

Yep, that's pretty much what i did. Thank you ๐Ÿ‘

from zerolog.

Dragomir-Ivanov avatar Dragomir-Ivanov commented on July 28, 2024

@asdine Can you post here an example of your implementation? I need exactly the same thing, and it is not immediately obvious how to do it. Thanks a lot!

from zerolog.

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.