Skip to content
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

Using klog in the examples #3

Closed
mauriciopoppe opened this issue Apr 6, 2022 · 3 comments
Closed

Using klog in the examples #3

mauriciopoppe opened this issue Apr 6, 2022 · 3 comments

Comments

@mauriciopoppe
Copy link

Thank you for the blogposts and for these snippets! I think it's very useful to see the timestamps in the examples that you have, I was wondering if you'd be ok if I submit a change replacing fmt.Printf with klog.Infof

@iximiuz
Copy link
Owner

iximiuz commented Apr 7, 2022

Hi Mauricio! I think it will be a great improvement for the mini-programs indeed!

Have you considered using go-logr/logr for that? It's a flexible logging interface that can be backed by many concrete logger implementations, including klog.

@mauriciopoppe
Copy link
Author

Thanks for the suggestion, I tried using klogr and while it might be great for a full fledged application I think the output makes it a little bit confusing if you're not aware of what it does, for example the output for crud-dynamic-example becomes:

go run main.go
I0407 21:35:54.874965 3335273 main.go:61]  "msg"="Created ConfigMap"  "name"="crud-dynamic-simple-2xz78" "namespace"="default"
I0407 21:35:54.919574 3335273 main.go:81]  "msg"="Read ConfigMap"  "name"="crud-dynamic-simple-2xz78" "namespace"="default"
I0407 21:35:54.969407 3335273 main.go:102]  "msg"="Updated ConfigMap"  "name"="crud-dynamic-simple-2xz78" "namespace"="default"
I0407 21:35:55.016497 3335273 main.go:121]  "msg"="Deleted ConfigMap"  "name"="crud-dynamic-simple-2xz78" "namespace"="default"

I was thinking that these examples are short enough to use std libraries and using things like klog might be an overkill, I think I'm going to use klog in some of the examples that you have but in my fork.

@iximiuz
Copy link
Owner

iximiuz commented Apr 8, 2022

On second thought, keeping the mini-programs dependencies at the bare minimum probably might be even more important than rich logging. Thanks for opening this issue anyway, it was good food for thought!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants