That may be (still IMH-Experience in the majority of cases, this is the proper default to go).
But the main concern to express here is, the default logger should accept an interface like *Output* instead of *io.Writer*. That way any necessary mechanism can be added without touching the log package, which is used in many packages. Best would be if it could just accept the same logger interface as the destination. And if the log package is going to change to support leveled logging (or another package is going to be added for this purpose), it's the best if the destination could accept object themselves, not a byte slice (*[]byte*). On Monday, August 14, 2017 at 3:03:00 AM UTC+4:30, Axel Wagner wrote: > > I'd consider it quite sensible to log an error *and* handle it (e.g. by > retrying). In that case, I wouldn't want it to appear with error-severity > in my log - it might be an error string, but it's not an error condition. > Only after bailing on handling an error should it stand out in an error > log. So I don't really agree with that approach, fine as it is. > > Just my 2¢. > > On Sun, Aug 13, 2017 at 8:59 PM, dc0d <kaveh.sh...@gmail.com <javascript:> > > wrote: > >> 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 golang-nuts...@googlegroups.com <javascript:>. >> For more options, visit https://groups.google.com/d/optout. >> > > -- 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 golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.