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.shahbaz...@gmail.com> 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+unsubscr...@googlegroups.com.
> 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.

Reply via email to