Many packages use the built-in log package. It could log data with help
from it's type. If we could set the output of the logger to something other
than *io.Writer*, like:
type Output interface {
Printf(format string, vset ...interface{})
Flags() (flag int)
Prefix() (prefix string)
SetFlags(flag int)
SetPrefix(prefix string)
}
Then, inside the output handler we could perform proper actions for logging
the data. Usual informative data would just get logged, and error would get
logged as error - as it should be. *logger.Error(err)* looks unnecessary
redundant to me (as in leveled loggers). If it's an error, it's an error.
We could even have other types/interfaces that we could take proper action
based on their type/interface much more flexible than just having 5 or 7 or
10 levels.
This package <https://github.com/dc0d/logt> demonstrates this idea. All
data gets logged as info and if it is/contains error, it gets logged as
error (hence, two levels). Most functions from standard log package are
implemented.
--
You received this message because you are subscribed to the Google Groups
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.