-
Notifications
You must be signed in to change notification settings - Fork 18k
log: add Llevel flag and OutputL() function #49239
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
Comments
Change https://golang.org/cl/359994 mentions this issue: |
Isn't this already possible with SetPrefix? |
Thanks for reply. I stronglly agree the point is which part should be in the std lib, and which is just part of external package. SetPrefix is possible. I have try it in my project mlog, mlog.go. It needs four *log.Logger and a locker, for Debug, Warn, Info, Error. For example:
|
There is an other experiment, syslog. syslog is heavy level depend logger. If std log supplies OutputL(), syslog can be easy divided into level interface functions(Emerg, Alert, Crit, Err...) and a network connective Writer. It is easy to keep same level interface functions, and replace with another Writer, for example, ansi color console, roolling file, NATS etc. Or using MultiWriter outputs log messages simultaneously. |
See relevant #48503 |
Some code I am working with take level string:
OutputL(calldepth int, level, s string) error
outputl(calldepth int, level, s string) error
I have worked on log4go and nxlog4go for few years. The 3rd log alway face three problem:
After compare few solutions, I found:
The level type should be string. It is better than int.
Do not implement too much interface functions in std log. Let the 3rd log do it.
Do not implement level filter in std log. Let the 3rd log do it.
New OutputL function receives the level string and writes it to the beginning of the log line.
The text was updated successfully, but these errors were encountered: