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

Make logs not go to stderr by default #8

Closed
ErlendFax opened this issue Aug 31, 2022 · 7 comments
Closed

Make logs not go to stderr by default #8

ErlendFax opened this issue Aug 31, 2022 · 7 comments
Labels
enhancement New feature or request

Comments

@ErlendFax
Copy link

All logs from Metamorphosis is displayed as error in Google Logging - even if the log level is debug or info ... pretty annoying!

image

From this discussion, it seems the reason is that logrus sends all logs to stderr. Someone suggests a solution/workaround in the thread, but swapping to another log lib isn't much work either I would guess.

@ErlendFax ErlendFax added the enhancement New feature or request label Aug 31, 2022
@perbu
Copy link
Member

perbu commented Sep 1, 2022

Hi Erlend.

I'm thinking I'm gonna see if I can drop logrus as a dependency and just log using the stdlib. Doing log levels is a bit more setup then, but it is manageable.

For when I get around to it, this seems sane: https://www.ardanlabs.com/blog/2013/11/using-log-package-in-go.html

@ErlendFax
Copy link
Author

Cool!

I'm not a Golang developer so can't suggest much, unfortunately.

@ErlendFax
Copy link
Author

Are contributions welcome? I'm considering trying it myself.

@perbu
Copy link
Member

perbu commented Oct 6, 2022

Yes, ofc. I'll get to around to it someday myself, but if you wanna lend a hand that would be great. My idea was something like this:

  1. make a local package "log" / remove the dependency on logrus.
  2. Implement log.Fatal, log.Error, log.Warn, log.Debug and log.Trace there
  3. Have the log.Warn and log.Error go to stderr
  4. Have the log.Info go to stdout
  5. Hide all log.Debug behind a constant, build flag or parameter

Sounds doable, I think.

@edoger
Copy link

edoger commented Oct 9, 2022

logrus is not very interested in fixing this problem at the moment. The PR submitted has been in an unmerged state. In the current state, if you must keep the use style of logrus, you can replace it with the log library zkits-logger I built for this purpose.

@perbu
Copy link
Member

perbu commented Nov 22, 2022

@ErlendFax Could you have a look at #18 and tell me what you think?

@ErlendFax
Copy link
Author

Looks good in GKE! Thanks! 💯

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

No branches or pull requests

3 participants