Zap Operations
Jump to navigation
Jump to search
Internal
Installation
In the directory that contains go.mod
:
go get -u go.uber.org/zap
Typical Usage
import "go.uber.org/zap"
...
var config zap.Config
var logger *zap.Logger
var sugaredLogger *zap.SugaredLogger
outputPath := "stderr" // ... or a local path
config = zap.NewDevelopmentConfig()
config.OutputPaths = []string{outputPath}
config.ErrorOutputPaths = []string{outputPath}
logger, err := config.Build()
if err != nil {
panic(err)
}
sugaredLogger = logger.Sugar()
sugaredLogger.Infof("somehting")