funcgetEncoder() zapcore.Encoder { encoderConfig := zap.NewProductionEncoderConfig() // The format time can be customized encoderConfig.EncodeTime = zapcore.ISO8601TimeEncoder encoderConfig.EncodeLevel = zapcore.CapitalLevelEncoder return zapcore.NewConsoleEncoder(encoderConfig) }
// Save file log cut funcgetLogWriter() zapcore.WriteSyncer { lumberJackLogger := &lumberjack.Logger{ Filename: "./nuke.log", // Log name MaxSize: 10, // File content size, MB MaxBackups: 5, // Maximum number of old files retained MaxAge: 30, // Maximum number of days to keep old files Compress: false, // Is the file compressed } return zapcore.AddSync(lumberJackLogger) }