logger: add NewStdLogger that can be used as std *log.Logger
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
parent
f386bffd37
commit
1d16983b67
19
logger/stdlogger.go
Normal file
19
logger/stdlogger.go
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
package logger
|
||||||
|
|
||||||
|
import (
|
||||||
|
"log"
|
||||||
|
)
|
||||||
|
|
||||||
|
type stdLogger struct {
|
||||||
|
l Logger
|
||||||
|
level Level
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewStdLogger(l Logger, level Level) *log.Logger {
|
||||||
|
return log.New(&stdLogger{l: l, level: level}, "" /* prefix */, 0 /* flags */)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (sl *stdLogger) Write(p []byte) (int, error) {
|
||||||
|
sl.l.Log(sl.l.Options().Context, sl.level, string(p))
|
||||||
|
return len(p), nil
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user