Giter Site home page Giter Site logo

View logs with verbosity level set about logr HOT 4 CLOSED

go-logr avatar go-logr commented on August 16, 2024
View logs with verbosity level set

from logr.

Comments (4)

pohly avatar pohly commented on August 16, 2024

How do I ensure these logs get printed, when I do want to view the logs at this verbosity level ?

That is determined by the Logger implementation that you are using. For example, klog has a -v parameter that sets the threshold.

from logr.

ssmails avatar ssmails commented on August 16, 2024

we use the below to set the Logger

ctrl "sigs.k8s.io/controller-runtime"

opts := zap.Options{
	Development: true,
}

ctrl.SetLogger(zap.New(zap.UseFlagOptions(&opts)))

Then use that Logger.
reconciler := &controllers.GatewayConfigReconcilerLog{
Log: ctrl.Log.WithName("controllers").WithName("GatewayConfig"),
}

GatewayConfigReconcilerLog is using below,
type GatewayConfigReconcilerLog struct {
Log logr.Logger
}

Now, when I have the Development mode set to true as above in the Logger options, I would expect to see level 10 logs printed, but I dont. As per docs of this package debug is level 10.
l.Log.V(10).Info("req reconciled", "req", req.NamespacedName)

from logr.

pohly avatar pohly commented on August 16, 2024

What is this zap package here?

You have to configure zap to enable log levels that are even lower (numerically) than Debug. See this code:

from logr.

thockin avatar thockin commented on August 16, 2024

https://github.com/go-logr/zapr/blob/master/example/main.go#L42-L47 show a trivial example of setting the zapr level, too.

from logr.

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.