-
Notifications
You must be signed in to change notification settings - Fork 72
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
More debug output #190
More debug output #190
Conversation
It's useful to be able to run with debug logging, which you can do now with: make run LOG_LEVEL=debug As a companion change, logging from `make run` is now explicitly set to console format, since the expectation is it will be run from a console. Signed-off-by: Michael Bridgen <[email protected]>
This commit finesses the use of the debug log a little, and introduces a trace log. The trace log gets threaded through calls to utility procedures -- it's a little awkward putting loggers into func parameters and structs, but it always is. Signed-off-by: Michael Bridgen <[email protected]>
a42038a
to
f011f23
Compare
@@ -229,7 +239,7 @@ func (r *ImageUpdateAutomationReconciler) Reconcile(ctx context.Context, req ctr | |||
} | |||
} | |||
|
|||
log.V(debug).Info("cloned git repository", "gitrepository", originName, "ref", ref, "working", tmp) | |||
debuglog.Info("cloned git repository", "gitrepository", originName, "ref", ref, "working", tmp) |
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.
Wouldn't it be better to log this before the attempt, so that it automatically adds context to any error that may happen during the attempt?
Reason I think this is a better approach, is because reconcilers generally do 3 things while performing operations for a resource:
- Logging (to tell what is about to happen, or highlight important information during an action).
- Events, to make certain things that have happened easily accessible to users and machines for observation.
- Conditions, to advertise observed state. Most often recorded after a reconciler has run an action that changed state, or when it inspected it.
There is some overlap in 1 and 2, but what distinguishes it for me is that 2 in all scenarios I have seen thus far, it never happens before something has taken place, which means that it would be a better task for logging.
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.
Yes it would, and that is a well-reasoned insight 👍
- trace different code paths, e.g., how the push branch is chosen - move debug output so it records things not already covered by e.g., errors, events Signed-off-by: Michael Bridgen <[email protected]>
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.
The lines that have been added and/or changed look like they adhere to the guidelines I had in mind.
Thank you @squaremo ✨
This adds trace-level messages to the log, in particular for