-
-
Notifications
You must be signed in to change notification settings - Fork 471
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
feat(logging): using new package containing logrus.Logger instead of global scope logrus (closes #583) (#699, @Shanduur) #699
Conversation
Hi @shanduur , thanks for opening this PR! EDIT: I changed the PR base branch to EDIT 2: if that's too much work and you don't have the time to do it, I can try my hand on porting your changes accordingly. Let me know 👍 |
I'll fix that! |
53675c2
to
b8f7587
Compare
Signed-off-by: Mateusz Urbanek <mateusz.urbanek.98@gmail.com>
b8f7587
to
5e073f8
Compare
@iwilltry42 could you look at failed tests? I am not sure if this is something broken by me. |
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 have to admit.. that was a quite repetitive review 😂
Thanks a lot for your effort in this @shanduur !
I have some change requests though, which are rather small and most result from the search-replace flow I guess.
UPDATE: committed the suggestions now, so the PR should be ready to merge once the tests pass ✔️
} else if pluginFound { | ||
os.Exit(0) | ||
} | ||
} | ||
} | ||
if err := cmd.Execute(); err != nil { | ||
log.Fatalln(err) | ||
l.Log().Fatalln(err) | ||
} | ||
} | ||
|
||
// initLogging initializes the logger | ||
func initLogging() { |
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.
TODO for later (no need to do it in this PR): move this to the logger package with functions to set k3d defaults and proper config structs.
I guess this would make sense to have it defined in pkg/
instead of the CLI (cmd/
) path/package.
@@ -175,7 +175,7 @@ func GetDockerClient() (*client.Client, error) { | |||
} | |||
|
|||
newClientOpts := flags.NewClientOptions() | |||
newClientOpts.Common.LogLevel = log.GetLevel().String() // this is needed, as the following Initialize() call will set a new log level on the global logrus instance | |||
newClientOpts.Common.LogLevel = l.Log().GetLevel().String() // this is needed, as the following Initialize() call will set a new log level on the global logrus instance |
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 guess this could be dropped now, as k3d itself doesn't use the global logrus instance anymore.. but it's not that important and maybe it could even be useful to cascade the log level down to the docker client 🤔
Co-authored-by: Thorsten Klein <iwilltry42@gmail.com>
Thanks a lot for the time and effort @shanduur :) |
@all-contributors please add @shanduur for code |
I've put up a pull request to add @shanduur! 🎉 |
What
This PR is intended to close issue #583 . New package
logger
was introduced and all usages oflogrus.Something
were replaced withl.Log().Something
, e.g.:Why
Due to the #583 .
Implications
It does not affect the behavior of the CLI, but it can affect all 3rd party users of k3d packages. As the global scope
logrus
is no longer used, it can create mismatch between log level ofk3d
packages and other packages importingk3d
packages using global scopelogrus
.