go-logging icon indicating copy to clipboard operation
go-logging copied to clipboard

Question: Can you set maximum logging level

Open pelletier197 opened this issue 5 years ago • 1 comments

Hello,

I am trying to accomplish a logging on different channel depending on the level of the log.

  • If logging level is <= Warning, then log to stdout
  • if logging level is >= Error, then log to stderr

Is there a way to get this work ?

For now I got

	backend := logging.NewLogBackend(os.Stdout, "", 0)
	leveledConsoleBackend = logging.AddModuleLevel(backend)
        // ...
	errorBackend := logging.NewLogBackend(os.Stderr, "", 0)
	leveledConsoleErrorBackend = logging.AddModuleLevel(errorBackend)
	leveledConsoleErrorBackend.SetLevel(logging.ERROR, "")

	logging.SetBackend(leveledConsoleErrorBackend, leveledConsoleBackend)

But with this, I see error logs output both in Stdoud and Stderr

Thank you for your help!

pelletier197 avatar Jun 24 '20 15:06 pelletier197

I opened a ticket in July lol, waiting for a response :(

ORESoftware avatar Sep 18 '20 19:09 ORESoftware