Documentation ¶
Overview ¶
Package logging provides logging functionality for gnet server, it sets up a default logger (powered by go.uber.org/zap) which is about to be used by gnet server, it also allows users to replace the default logger with their customized logger by just implementing the `Logger` interface and assign it to the functional option `Options.Logger`, pass it to `gnet.Serve` method.
There are two logging modes in zap, instantiated by either NewProduction() or NewDevelopment(), the former builds a sensible production Logger that writes InfoLevel and above logs to standard error as JSON, it's a shortcut for NewProductionConfig().Build(...Option); the latter builds a development Logger that writes DebugLevel and above logs to standard error in a human-friendly format, it's a shortcut for NewDevelopmentConfig().Build(...Option).
Index ¶
- func Cleanup()
- func Debugf(format string, args ...interface{})
- func Errorf(format string, args ...interface{})
- func Fatalf(format string, args ...interface{})
- func Infof(format string, args ...interface{})
- func Init(logLevel zapcore.Level)
- func Level() zapcore.Level
- func LogErr(err error)
- func SetupLogger(logger Logger, logLevel zapcore.Level)
- func SetupLoggerWithPath(localPath string, logLevel zapcore.Level) (err error)
- func Warnf(format string, args ...interface{})
- type Logger
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Cleanup ¶
func Cleanup()
Cleanup does something windup for logger, like closing, flushing, etc.
func SetupLogger ¶
SetupLogger setups the logger by the Logger interface.
func SetupLoggerWithPath ¶
SetupLoggerWithPath setups the logger by local file path.
Types ¶
type Logger ¶
type Logger interface { // Debugf logs messages at DEBUG level. Debugf(format string, args ...interface{}) // Infof logs messages at INFO level. Infof(format string, args ...interface{}) // Warnf logs messages at WARN level. Warnf(format string, args ...interface{}) // Errorf logs messages at ERROR level. Errorf(format string, args ...interface{}) // Fatalf logs messages at FATAL level. Fatalf(format string, args ...interface{}) }
Logger is used for logging formatted messages.
var ( // DefaultLogger is the default logger inside the tbuspp client. DefaultLogger Logger )