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

[log] debug log in init functions would never show #60

Closed
at15 opened this issue Feb 26, 2018 · 1 comment · Fixed by #111
Closed

[log] debug log in init functions would never show #60

at15 opened this issue Feb 26, 2018 · 1 comment · Fixed by #111

Comments

@at15
Copy link
Member

at15 commented Feb 26, 2018

because cli set the level after the init functions has been called ...

we should be able to enable that by setting the default level using ldflag, so even debug in init function would work

at15 added a commit to benchhub/benchhub that referenced this issue Feb 26, 2018
- the log is not shown because debug level log in `init` function would
never show, the logging level is adjusted after `init` function is
called, dyweb/gommon#60 need to change default
logging level at compile time to allow debug log in `init` ...
  - this also applies to package level variables, which are created
before init function (..right?)
@at15 at15 added this to the 0.0.8 milestone Sep 6, 2018
@at15 at15 removed this from the 0.0.8 milestone Dec 9, 2018
@at15 at15 added this to the 0.0.11 milestone Apr 26, 2019
@at15
Copy link
Member Author

at15 commented Apr 26, 2019

one way to avoid using ldflag is check a fixed environment variable like GOMMON_LOG_LEVEL, when using vendor I think it was possible to set ldflag for dependencies, when using go mod I am not sure if it is possible, also this makes application using library change their build flags as well

at15 added a commit that referenced this issue Apr 27, 2019
- previously the default is hard coded to info level, which is fine
until you start adding debug level log in `init` func, normally when you
change log level use command flag, the `SetLevel` is called in main
package, at that time, all the `init` has being called
- by using env var, the gommon/log package itself's `init` can check
environment variable directly, since all the packages that use gommon
log have their `init` called **after** gommon's, even if they use debug
in `init` they can still see the message if they set the correct
level in environment variable
- it is not tested, might need to add e2e test
@at15 at15 closed this as completed in #111 Apr 28, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant