-
Notifications
You must be signed in to change notification settings - Fork 729
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor logging configuration #1699
Conversation
} | ||
} | ||
|
||
func getVersionString() string { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the pkg/controller/common/version package might be what you want here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IIRC the version package only contains functions for parsing a version string into constituent parts. I am just trying to concatenate the version string with the build hash here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah yeah my bad I was translating hash to label in my head
Do we want to do this? I thought in #305 we had decided that we only wanted two levels of logging (debug/info), so wonder if I missed a discussion somewhere.
👍
Can you clarify the reasoning for this one? Is it just so it's rather than
This might be worth waiting a week to make the change on the kubebuilder v2 feature branch IMO. |
I wasn't aware of the that discussion, thanks for pointing it out. On several occasions I found myself wanting to output things that didn't quite fit the Whether the team wants to use levels above 1 or not, I don't think there's any harm in being able to configure the output level from a flag though. WDYT?
Yes, because
This will continue to work on v2 it's just that it will have more configuration functions that we can use. Happy to wait if you feel this would add additional complexity to the migration. |
var opts []zap.Option | ||
if dev.Enabled { | ||
encoderConf := zap.NewDevelopmentEncoderConfig() | ||
encoderConf.EncodeLevel = zapcore.CapitalColorLevelEncoder |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice to have colors :)
Docs build is failing due to this change: elastic/docs#1172 |
635961c
to
2b4ab2a
Compare
+1 with that, I also find myself wanting a V(2) in some situations. Mostly for logs that are pure debugging (sometimes JSON dumps), which I consider different from V(1) that reports what's going on. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍
Looking forward to the reconciliation with controller-runtime v0.2.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One question, LGTM otherwise.
|
||
var ( | ||
verbosity = flag.Int("log-verbosity", 0, "Verbosity level of logs (-2=Error, -1=Warn, 0=Info, >0=Debug)") | ||
enableDebugLogs = flag.Bool("enable-debug-logs", false, "Enable debug logs") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this still needed? It seems to only be used to enable the same behavior as verbosity flag does.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mainly kept it for backward compatibility as we have documented it in the troubleshooting docs and it's much more obvious to a casual user what enable-debug-logs
would do compared to log-verbosity=1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed, we probably don't want multiple ways to do the same thing. But I could definitely be missing a use case
encoderConf := zap.NewProductionEncoderConfig() | ||
encoderConf.MessageKey = "message" | ||
encoderConf.TimeKey = "@timestamp" | ||
encoderConf.EncodeTime = zapcore.ISO8601TimeEncoder |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
@@ -76,7 +79,7 @@ dep: | |||
|
|||
dep-vendor-only: | |||
# don't attempt to upgrade Gopkg.lock | |||
dep ensure --vendor-only | |||
dep ensure --vendor-only |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
I don't really run into this much personally. I think if we do want this we will probably want to update the troubleshooting or development docs to make it clear what the difference is between log levels and how to use them. |
Ah cool, the initialization code is getting heavily reworked atm but it looks like it should just be adding a flag so I think we're good from that perspective |
This change does the following:
log.V(2)
etc. should actually work as intended now)message
(StackDriver logging can render logs nicely if this key exists)@timestamp
ver
key to report operator version in log linesAs we are currently on controller-runtime v0.1,
log.InitLogger
is much more complicated than it needs to be. When we migrate to controller-runtime v0.2 it can be simplified.The suggestion in #1587 to be compatible with ECS logging format by renaming
logger
tolog.level
andlevel
tolog.level
didn't seem to add much benefit at this point so I have left the shorter keys in place to aid readability.Fixes #1587