Giter Site home page Giter Site logo

Comments (8)

mabdh avatar mabdh commented on August 17, 2024 1

@rohilsurana i see, sounds good. should we do that approach for now (for logrus only) ?

from salt.

rahmatrhd avatar rahmatrhd commented on August 17, 2024

what if we also add a similar getter method in the Logger interface that returns interface{}. The user can cast it to the specific logger instance that they're using either it is logrus, zap, or anything else.

from salt.

mabdh avatar mabdh commented on August 17, 2024

@rahmatrhd I was also thinking that approach as the alternative but returning interface in interface does not looks solid to me personally. But if everybody is okay with that, it is fine.

from salt.

kushsharma avatar kushsharma commented on August 17, 2024

I think its better to not modify the interface because at least the usecase mentioned by @mabdh doesn't really need it, we can get away by providing a getter in Logrus struct. One more thing I noticed in grpc_middleware is grpc_logrus can take *logrus.Entry so should we instead create a NewEntry method in Logrus to avoid users modifying core struct?

from salt.

mabdh avatar mabdh commented on August 17, 2024

@kushsharma yes, returning *logrus.Entry would be more appropriate IMO.

from salt.

rohilsurana avatar rohilsurana commented on August 17, 2024

For this specific case *logrus.Entry might suffice.

But for a larger discussion I think we should instead go for more of an injecting approach, where we can inject our own logrus.Logger instance if needed to initialise. We could use an option for doing this, like -

func LogrusWithLogger(logger *logrus.Logger) Option

This allows us to apply our defaults/options onto the logger as well as keep an handle of it to use it elsewhere or even modify its properties.

We could follow same pattern for other loggers for a similar looking API for all loggers.

from salt.

mabdh avatar mabdh commented on August 17, 2024

@rohilsurana even if we do so, how does it solve the problem

we want to get `*logrus.Logger` from salt `log.Logger`

?

Because the log.NewLogrus will only return the wrapper of *logrus.Logger which is *log.Logrus

from salt.

rohilsurana avatar rohilsurana commented on August 17, 2024

We keep a pointer to the injected logrus.Logger on our side and use it.

from salt.

Related Issues (15)

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.