Skip to content
This repository has been archived by the owner on Mar 18, 2019. It is now read-only.

Minimal log level #19

Open
luqasz opened this issue Nov 1, 2016 · 5 comments
Open

Minimal log level #19

luqasz opened this issue Nov 1, 2016 · 5 comments

Comments

@luqasz
Copy link

luqasz commented Nov 1, 2016

Hi

Is there any way to set loggers log level ? I would like to log messages up to LOG_ERR.

@sirsean
Copy link
Contributor

sirsean commented Nov 1, 2016

You can set the "default" log level for messages when you dial:

w, err := srslog.Dial("", "", srslog.LOG_ERR, "testtag")

That will use LOG_ERR when you call w.Write. But you can use the same writer to send messages with different log levels, using w.Info, w.Debug, etc.

You can also use different log levels programmatically using w.WriteWithPriority, passing in srslog.LOG_WARNING, etc.

Is that what you wanted?

@luqasz
Copy link
Author

luqasz commented Nov 1, 2016

What If I do

w, err := srslog.Dial("", "", srslog.LOG_ERR, "testtag")

abd then later call w.Info("message"). I do not want this message to be send since I've set logger to sendsrslog.LOG_ERR` and higher priorities.

@sirsean
Copy link
Contributor

sirsean commented Nov 1, 2016

Oh, now I understand.

No, it doesn't currently work that way. The log level you pass into Dial is the "default" log level for messages that you haven't specifically specified a log level for.

There is currently no concept of "minimum" level, within the library.

@luqasz
Copy link
Author

luqasz commented Nov 1, 2016

Ok. Thx for info.
Do you know any library that has this concept ?

@luqasz
Copy link
Author

luqasz commented Nov 1, 2016

NVM. found one

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

No branches or pull requests

2 participants