Add documentation for logger

This commit is contained in:
9seconds
2021-04-05 16:55:26 +03:00
parent 0274b3436a
commit 0dd890a09d
4 changed files with 33 additions and 0 deletions
+9
View File
@@ -1,5 +1,14 @@
// Package logger has implementation of loggers for mtglib.Logger
// interface.
//
// Please see a description of that interface to get some agreements
// which are used by mtglib.
package logger
// StdLikeLogger is an interface which is close to log.Logger. This is
// commonly used by many 3pp tools. While mtglib itself does not need
// it, it is always a good idea to support it and have a transient end
// to end logging.
type StdLikeLogger interface {
Printf(format string, args ...interface{})
}
+1
View File
@@ -15,6 +15,7 @@ func (n noopLogger) InfoError(_ string, _ error) {}
func (n noopLogger) WarningError(_ string, _ error) {}
func (n noopLogger) DebugError(_ string, _ error) {}
// NewNoopLogger returns a logger which discards all events.
func NewNoopLogger() mtglib.Logger {
return noopLogger{}
}
+1
View File
@@ -114,6 +114,7 @@ func (z *zeroLogContext) attachCtx(evt *zerolog.Event) {
}
}
// NewZeroLogger returns a logger which is using rs/zerolog library.
func NewZeroLogger(log zerolog.Logger) mtglib.Logger {
return &zeroLogContext{
log: &log,