-
Notifications
You must be signed in to change notification settings - Fork 21
Description
Two of your types don't allow for implementing custom loggers outside of your package because the fields are internal to the package.
In particular:
type Valuer interface {
getValue() interface{}
}
If this was instead:
type Valuer interface {
Value() interface{}
}
then other packages could implement loggers that can access the value of the Valuer
. As it is currently written, only loggers you define in your log package can access the value of a Valuer
.
I get that you're using Valuer
interface to get around passing any
, but I think passing any
would be better. Instead you've redefined any
to be a struct, when newer versions of go already support any
aliased to interface{}
.
Additionally, LoggedError
has internal fields and is not an interface. Recommend that this be changed from a struct to an interface.
type LoggedError struct {
err error
}
func (l LoggedError) Err() error {
return l.err
}
func (l LoggedError) Nil() error {
return nil
}
instead consider:
type LoggedError interface {
Err() error
Nil() error
}
type LoggedErrorImpl struct {
err error
}
func (l LoggedErrorImpl) Err() error {
return l.err
}
func (l LoggedErrorImpl) Nil() error {
return nil
}
I'm also not sure I understand the purpose of a Nil()
func that always returns nil
.