Git Product home page Git Product logo

Comments (7)

deankarn avatar deankarn commented on September 27, 2024 1

Hey @sebastianwebber I think I’ve got most of it done already in a local branch, just finalizing how I want to do the stack trace stuff, I’ll let you know if I could use help with anything though :)

from log.

deankarn avatar deankarn commented on September 27, 2024 1

ok @sebastianwebber @Perlence I finally got around to updating this library and it now supports sharing fields between entries!

sorry for how long it took, just be so busy with....everything.

from log.

deankarn avatar deankarn commented on September 27, 2024

Hey @Perlence

No you haven't missed anything, when I was designing, I wanted to make sure that log was safe to be called from multiple goroutines and if the Entry was reusable then a possibility exists that someone could call it from multiple goroutines and cause themselves problems.

I do however understand your scenario and could look into creating a Release option or function to tell the Entry not to put itself and fields back into the pool.

Would that be something you'd be interested in.?
eg.

// Calling Release() releases the Entry and all fields from
// being managed by the package...
l := log.WithFields(...).Release()

l.Info(...)

I can't promise anything, but I could look into this sort of functionality.

from log.

Perlence avatar Perlence commented on September 27, 2024

Thank you for reply. I really don't want to force you to make decisions that you'll regret later, so everything is completely up to you 😄

I think that while Release allows to log same fields multiple times, it cannot be used to add one-off fields, e.g. some error information, and then log an entry with initial fields, because WithFields adds fields in place. So there could be something like (*Entry) CopyWithFields. But I'd like to see one method that can be used either to fix fields for later use or to copy existing fields into a new Entry.

"Release" also doesn't sound too clear to me, kind of low level, for example I didn't know about entry pool before fields started to "leak" through to other entries when I used context multiple times.

from log.

deankarn avatar deankarn commented on September 27, 2024

Thanks for the ideas, let me think about how and if I could achieve this.

CopyWithFields() does seem like a good solution!

It may take me a bit to get to this as I'm adding new things to some of my other packages also, but I will get to this 😄

from log.

sebastianwebber avatar sebastianwebber commented on September 27, 2024

@joeybloggs do you need help to implement this feature?

from log.

sebastianwebber avatar sebastianwebber commented on September 27, 2024

nice @joeybloggs

For now, i'm using:

...
log := log.WithFields(log.F("key", "value"))

log.Info("bla")
...

from log.

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.