Comments (4)
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.
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.
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:
- https://github.com/go-logr/zapr/blob/df10f4788c061a53564cebafc055fd9ad3f3255e/zapr.go#L194-L202
- https://github.com/kubernetes/kubernetes/blob/f02682c628c530219966a00ae002d799f0d813dc/staging/src/k8s.io/component-base/logs/json/json.go#L38-L77
from logr.
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)
- logr cannot log struct fields which are not exposed HOT 5
- testing: testing.T.Log panics when called after test completion HOT 1
- Feature request; GetV() function HOT 3
- What level does klog.Warning map to? HOT 3
- Make the zero value useful HOT 3
- Are WithName, WithValues, WithCallDepth thread safe methods? HOT 2
- New release to ship #143 HOT 6
- funcr: invalid json when omitting fields HOT 2
- my maps project
- WithValues with the same key repeats the field HOT 4
- Create `slogr` implementation for `slog` package HOT 6
- Create `charmbracelet/log` implementation HOT 3
- why `V` function make level additive? HOT 2
- How could I transfer the caller information into Json format? HOT 5
- Add minimal permissions to GitHub workflows
- Add a security policy
- PR #166 introduced a breaking change in a patch release HOT 7
- Why use WithName() HOT 7
- Add OpenSSF Scorecard workflow HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from logr.