Documentation ¶
Overview ¶
Package log defines the logger for the sdk.
Index ¶
- Variables
- func Debug(args ...interface{})
- func Debugf(format string, args ...interface{})
- func EnableTrace()
- func Error(args ...interface{})
- func Errorf(format string, args ...interface{})
- func Fatal(args ...interface{})
- func Fatalf(format string, args ...interface{})
- func Info(args ...interface{})
- func Infof(format string, args ...interface{})
- func SetLogLevel(level string) error
- func SetLogPath(path string) error
- func SetLogger(logger Logger)
- func Trace(args ...interface{})
- func Tracef(format string, args ...interface{})
- func Warn(args ...interface{})
- func Warnf(format string, args ...interface{})
- type Level
- type Logger
- type OutputConfig
- type ZapLogWrapper
- func (z *ZapLogWrapper) Debug(args ...interface{})
- func (z *ZapLogWrapper) Debugf(format string, args ...interface{})
- func (z *ZapLogWrapper) Error(args ...interface{})
- func (z *ZapLogWrapper) Errorf(format string, args ...interface{})
- func (z *ZapLogWrapper) Fatal(args ...interface{})
- func (z *ZapLogWrapper) Fatalf(format string, args ...interface{})
- func (z *ZapLogWrapper) GetLogger() Logger
- func (z *ZapLogWrapper) Info(args ...interface{})
- func (z *ZapLogWrapper) Infof(format string, args ...interface{})
- func (z *ZapLogWrapper) Sync() error
- func (z *ZapLogWrapper) Trace(args ...interface{})
- func (z *ZapLogWrapper) Tracef(format string, args ...interface{})
- func (z *ZapLogWrapper) Warn(args ...interface{})
- func (z *ZapLogWrapper) Warnf(format string, args ...interface{})
- func (z *ZapLogWrapper) WithFields(fields ...string) Logger
Constants ¶
This section is empty.
Variables ¶
var LevelNames = map[string]Level{ "trace": LevelTrace, "debug": LevelDebug, "info": LevelInfo, "warn": LevelWarn, "error": LevelError, "fatal": LevelFatal, }
LevelNames log level name map
Functions ¶
func Debug ¶
func Debug(args ...interface{})
Debug logs to DEBUG level log. Arguments are handled in the manner of fmt.Print.
func Debugf ¶
func Debugf(format string, args ...interface{})
Debugf logs to DEBUG level log. Arguments are handled in the manner of fmt.Printf.
func Error ¶
func Error(args ...interface{})
Error logs to ERROR level log. Arguments are handled in the manner of fmt.Print.
func Errorf ¶
func Errorf(format string, args ...interface{})
Errorf logs to ERROR level log. Arguments are handled in the manner of fmt.Printf.
func Fatal ¶
func Fatal(args ...interface{})
Fatal logs to ERROR level log. Arguments are handled in the manner of fmt.Print. that all Fatal logs will exit with os.Exit(1).
func Fatalf ¶
func Fatalf(format string, args ...interface{})
Fatalf logs to ERROR level log. Arguments are handled in the manner of fmt.Printf.
func Info ¶
func Info(args ...interface{})
Info logs to INFO level log. Arguments are handled in the manner of fmt.Print.
func Infof ¶
func Infof(format string, args ...interface{})
Infof logs to INFO level log. Arguments are handled in the manner of fmt.Print.
func SetLogger ¶
func SetLogger(logger Logger)
SetLogger sets the default logger to the given logger.
func Trace ¶
func Trace(args ...interface{})
Trace logs to TRACE level log. Arguments are handled in the manner of fmt.Print.
func Tracef ¶
func Tracef(format string, args ...interface{})
Tracef logs to TRACE level log. Arguments are handled in the manner of fmt.Printf.
Types ¶
type Logger ¶
type Logger interface { // Trace logs to TRACE log. Arguments are handled in the manner of fmt.Print. Trace(args ...interface{}) // Tracef logs to TRACE log. Arguments are handled in the manner of fmt.Printf. Tracef(format string, args ...interface{}) // Debug logs to DEBUG log. Arguments are handled in the manner of fmt.Print. Debug(args ...interface{}) // Debugf logs to DEBUG log. Arguments are handled in the manner of fmt.Printf. Debugf(format string, args ...interface{}) // Info logs to INFO log. Arguments are handled in the manner of fmt.Print. Info(args ...interface{}) // Infof logs to INFO log. Arguments are handled in the manner of fmt.Printf. Infof(format string, args ...interface{}) // Warn logs to WARNING log. Arguments are handled in the manner of fmt.Print. Warn(args ...interface{}) // Warnf logs to WARNING log. Arguments are handled in the manner of fmt.Printf. Warnf(format string, args ...interface{}) // Error logs to ERROR log. Arguments are handled in the manner of fmt.Print. Error(args ...interface{}) // Errorf logs to ERROR log. Arguments are handled in the manner of fmt.Printf. Errorf(format string, args ...interface{}) // Fatal logs to ERROR log. Arguments are handled in the manner of fmt.Print. // that all Fatal logs will exit with os.Exit(1). // Implementations may also call os.Exit() with a non-zero exit code. Fatal(args ...interface{}) // Fatalf logs to ERROR log. Arguments are handled in the manner of fmt.Printf. Fatalf(format string, args ...interface{}) // Sync calls the underlying Core's Sync method, flushing any buffered log entries. // Applications should take care to call Sync before exiting Sync() error // // WithFields sets the user-defined data to the log and return a new Logger. WithFields(fields ...string) Logger }
Logger is an interface that abstracts behavior of the logger.
func NewLogger ¶
func NewLogger(config *OutputConfig) Logger
NewLogger will return a configured zap logger.
func WithFields ¶
WithFields is the proxy to call the WithFields of defaultLogger.
type OutputConfig ¶
type OutputConfig struct { // LogPath is the path for the log. LogPath string // Level is the log level. Level string // MaxSize is the max size for a rolling log. MaxSize int // MaxBackups is the maximum number of old log files to retain. MaxBackups int // MaxAge is the maximum number of days to retain old log files based on the // timestamp encoded in their filename. MaxAge int }
OutputConfig defines the output config which can be reconfigured by user.
type ZapLogWrapper ¶
type ZapLogWrapper struct {
// contains filtered or unexported fields
}
ZapLogWrapper implements Logger interface based on the underlying zapLog.
func (*ZapLogWrapper) Debug ¶
func (z *ZapLogWrapper) Debug(args ...interface{})
Debug logs to DEBUG log, Arguments are handled in the manner of fmt.Print
func (*ZapLogWrapper) Debugf ¶
func (z *ZapLogWrapper) Debugf(format string, args ...interface{})
Debugf logs to DEBUG log, Arguments are handled in the manner of fmt.Printf
func (*ZapLogWrapper) Error ¶
func (z *ZapLogWrapper) Error(args ...interface{})
Error logs to ERROR log, Arguments are handled in the manner of fmt.Print
func (*ZapLogWrapper) Errorf ¶
func (z *ZapLogWrapper) Errorf(format string, args ...interface{})
Errorf logs to ERROR log, Arguments are handled in the manner of fmt.Printf
func (*ZapLogWrapper) Fatal ¶
func (z *ZapLogWrapper) Fatal(args ...interface{})
Fatal logs to FATAL log, Arguments are handled in the manner of fmt.Print
func (*ZapLogWrapper) Fatalf ¶
func (z *ZapLogWrapper) Fatalf(format string, args ...interface{})
Fatalf logs to FATAL log, Arguments are handled in the manner of fmt.Printf
func (*ZapLogWrapper) GetLogger ¶
func (z *ZapLogWrapper) GetLogger() Logger
GetLogger returns the wrapped zap looger.
func (*ZapLogWrapper) Info ¶
func (z *ZapLogWrapper) Info(args ...interface{})
Info logs to INFO log, Arguments are handled in the manner of fmt.Print
func (*ZapLogWrapper) Infof ¶
func (z *ZapLogWrapper) Infof(format string, args ...interface{})
Infof logs to INFO log, Arguments are handled in the manner of fmt.Printf
func (*ZapLogWrapper) Sync ¶
func (z *ZapLogWrapper) Sync() error
Sync calls the zap defaultLogger's Sync method, flushing any buffered log entries. Applications should take care to call Sync before exiting.
func (*ZapLogWrapper) Trace ¶
func (z *ZapLogWrapper) Trace(args ...interface{})
Trace logs to TRACE log, Arguments are handled in the manner of fmt.Print
func (*ZapLogWrapper) Tracef ¶
func (z *ZapLogWrapper) Tracef(format string, args ...interface{})
Tracef logs to TRACE log, Arguments are handled in the manner of fmt.Printf
func (*ZapLogWrapper) Warn ¶
func (z *ZapLogWrapper) Warn(args ...interface{})
Warn logs to WARNING log, Arguments are handled in the manner of fmt.Print
func (*ZapLogWrapper) Warnf ¶
func (z *ZapLogWrapper) Warnf(format string, args ...interface{})
Warnf logs to WARNING log, Arguments are handled in the manner of fmt.Printf
func (*ZapLogWrapper) WithFields ¶
func (z *ZapLogWrapper) WithFields(fields ...string) Logger
WithFields sets the user-defined data to the log and return a new Logger.