package log
import "context"
type Helper struct {
l Logger
}
func For (l Logger ) Helper {
return Helper {l : OrNop (l )}
}
func (h Helper ) logger () Logger {
if h .l == nil {
return Nop
}
return h .l
}
func (h Helper ) Logger () Logger {
return h .logger ()
}
func (h Helper ) With (attrs ...Attr ) Helper {
return Helper {l : With (h .logger (), attrs ...)}
}
func (h Helper ) Named (name string ) Helper {
return Helper {l : Named (h .logger (), name )}
}
func (h Helper ) Enabled (ctx context .Context , level Level ) bool {
return h .logger ().Enabled (ctx , level )
}
func (h Helper ) Debug (ctx context .Context , msg string , attrs ...Attr ) {
h .logger ().Log (ctx , LevelDebug , msg , attrs ...)
}
func (h Helper ) Info (ctx context .Context , msg string , attrs ...Attr ) {
h .logger ().Log (ctx , LevelInfo , msg , attrs ...)
}
func (h Helper ) Warn (ctx context .Context , msg string , attrs ...Attr ) {
h .logger ().Log (ctx , LevelWarn , msg , attrs ...)
}
func (h Helper ) Error (ctx context .Context , msg string , attrs ...Attr ) {
h .logger ().Log (ctx , LevelError , msg , attrs ...)
}
The pages are generated with Golds v0.8.4 . (GOOS=linux GOARCH=amd64)
Golds is a Go 101 project developed by Tapir Liu .
PR and bug reports are welcome and can be submitted to the issue list .
Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds .