-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Improve logging #1171
Improve logging #1171
Conversation
e6245fd
to
07ef62a
Compare
MegaLinter status: ✅ SUCCESS
See errors details in artifact MegaLinter reports on CI Job page |
07ef62a
to
f146f94
Compare
Codecov Report
@@ Coverage Diff @@
## master #1171 +/- ##
==========================================
+ Coverage 57.50% 62.40% +4.89%
==========================================
Files 32 40 +8
Lines 4594 5402 +808
==========================================
+ Hits 2642 3371 +729
- Misses 1729 1769 +40
- Partials 223 262 +39
📣 Codecov can now indicate which changes are the most critical in Pull Requests. Learn more |
f146f94
to
3f72b7c
Compare
3f72b7c
to
6418bde
Compare
8292684
to
53cceb7
Compare
53cceb7
to
fface0a
Compare
0c75474
to
9ddded4
Compare
12bc9a1
to
d243b19
Compare
9ddded4
to
70c1a8a
Compare
@ZauberNerd this pull request is now in conflict 😩 |
@ZauberNerd this pull request has failed checks 🛠 |
4f49405
to
d0e8969
Compare
@ZauberNerd this pull request is now in conflict 😩 |
Co-authored-by: Markus Wolf <markus.wolf@new-work.se>
Co-authored-by: Markus Wolf <markus.wolf@new-work.se>
Co-authored-by: Markus Wolf <markus.wolf@new-work.se>
Co-authored-by: Markus Wolf <markus.wolf@new-work.se>
Co-authored-by: Markus Wolf <markus.wolf@new-work.se>
The container gets injected a job logger, but during the time that steps are run, we want to use the step logger. This commit wraps pre/main/post steps in an executor that replaces the job logger with a step logger. Co-authored-by: Markus Wolf <markus.wolf@new-work.se>
Co-authored-by: Markus Wolf <markus.wolf@new-work.se>
Co-authored-by: Markus Wolf <markus.wolf@new-work.se>
d0e8969
to
ce8f113
Compare
} else { | ||
err := info.stopContainer()(ctx) | ||
if err != nil { | ||
return err | ||
} | ||
info.result("success") | ||
logger.WithField("jobResult", "success").Infof("\U0001F3C1 Job succeeded") |
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 get a misleading logging message, this job doesn't succeed. I cancelled it.
🚀 Start image=ghcr.io/catthehacker/ubuntu:act-latest
🐳 docker pull image=ghcr.io/catthehacker/ubuntu:act-latest platform= username= forcePull=false
🏁 Job succeeded
Warning: unable to get git repo: unable to find git repo
Error: context canceled
Probably a bug, which hasn't surfaced earlier.
I'm testing this change against my selfhosted runner code
I cancelled while it was downloading the docker image for the job
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.
Seems to work fine.
I wonder why this single warning bypassed my logger, both global and context logger have an custom formatter. The later warnings of the same kind are working as expected and call my formatter.
time="2022-06-16T21:19:42+02:00" level=warning msg="unable to get git repo: unable to find git repo"
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.
Thanks for this @ZauberNerd - sorry for delays in review
Replace more of the global logger call sites with contextualized job/step loggers and add job/step id and results as fields to the JSON logger output.
This causes most debug logs to be printed with the job logger, which means they are now correctly prefixed with the job they belong to.
Also, having the ids and results in the JSON output helps in cases where the log is read by machines, because we now can attribute each line to a job/step.