Documentation ¶
Index ¶
- Constants
- Variables
- func Debug(args ...interface{})
- func Debugf(template string, args ...interface{})
- func Error(args ...interface{})
- func Errorf(template string, args ...interface{})
- func Fatal(args ...interface{})
- func Fatalf(template string, args ...interface{})
- func Info(args ...interface{})
- func Infof(template string, args ...interface{})
- func SetOptions(options ...Option)
- func Sync() error
- func Warn(args ...interface{})
- func Warnf(template string, args ...interface{})
- type Field
- type FileOption
- type FileOptions
- type Level
- type Log
- func (l *Log) Debug(msg string, fields ...Field)
- func (l *Log) Error(msg string, fields ...Field)
- func (l *Log) Fatal(msg string, fields ...Field)
- func (l *Log) Info(msg string, fields ...Field)
- func (l *Log) Sugar() *SugaredLogger
- func (l *Log) Sync() error
- func (l *Log) Warn(msg string, fields ...Field)
- type Logger
- type Option
- type Options
- type SugaredLogger
Constants ¶
const ( // ConsoleEncoder output the log with console ConsoleEncoder = "console" // JSONEncoder output the log with json format JSONEncoder = "json" )
Variables ¶
var ( // Any is alias of zap.Any Field Any = zap.Any // Bool is alias of zap.Bool Field Bool = zap.Bool // String is alias of zap.String Field String = zap.String // Float32 alias of zap.Float32 Field Float32 = zap.Float32 // Float64 is alias of zap.Float64 Field Float64 = zap.Float64 // Int is alias of zap.Int Field Int = zap.Int // Int8 is alias of zap.Int8 Field Int8 = zap.Int8 // Int16 is alias of zap.Intl6 Field Int16 = zap.Int16 // Int32 is alias of zap.Int32 Field Int32 = zap.Int32 // Int64 is alias of zap.Int64 Field Int64 = zap.Int64 // Uint is alias of zap.Uint Field Uint = zap.Uint // Uint8 is alias of zap.Uint8 Field Uint8 = zap.Uint8 // Vint16 is alias of zap.Uintl6 Field Uint16 = zap.Uint16 // Uint32 is alias of zap.Uint32 Field Uint32 = zap.Uint32 // Uint64 is alias of zap.Uint64 Field Uint64 = zap.Uint64 // Namespace is alias of zap.Namespace Field Namespace = zap.Namespace )
Functions ¶
func Debug ¶
func Debug(args ...interface{})
Debug logs a message at level Debug on the standard logger
func Debugf ¶
func Debugf(template string, args ...interface{})
Debugf logs a message at level Debug on the standard loggero
func Error ¶
func Error(args ...interface{})
Error logs a message at level Error on the standard loggero
func Errorf ¶
func Errorf(template string, args ...interface{})
Errorf logs a message at level Error on the standard loggero
func Fatal ¶
func Fatal(args ...interface{})
Fatal logs a message at level Fatal on the standard loggero
func Fatalf ¶
func Fatalf(template string, args ...interface{})
Fatalf logs a message at level Fatal on the standard loggero
func Infof ¶
func Infof(template string, args ...interface{})
Infof logs a message at level Info on the standard loggero
Types ¶
type FileOption ¶
type FileOption func(*FileOptions)
FileOption define a func wraps FileOptions
func WithCompress ¶
func WithCompress(compress bool) FileOption
WithCompress specify if the rotated files should be compressed using gzip
func WithFilename ¶
func WithFilename(filename string) FileOption
WithFilename specify the filename where log to write
func WithMaxAge ¶
func WithMaxAge(maxAge int) FileOption
WithMaxAge specify the maximum number days to retain old files based on the timestamp encoded in their filename
func WithMaxBackups ¶
func WithMaxBackups(maxBackups int) FileOption
WithMaxBackups specify the maximum number of old log files to retain
func WithMaxSize ¶
func WithMaxSize(maxSize int) FileOption
WithMaxSize specify maximum size in MB of the file before it gets rotated
type FileOptions ¶
type FileOptions struct {
// contains filtered or unexported fields
}
FileOptions define the file writer options
type Level ¶
Level is alias of zapcore.Level
const ( // DebugLevel logs are typically voluminous, and are usually disabled in production. DebugLevel Level = zap.DebugLevel // InfoLevel is the default logging priority. InfoLevel Level = zap.InfoLevel // WarnLevel logs are more important than Info, but don't need individual human review. WarnLevel Level = zap.WarnLevel // ErrorLevel logs are high-priority. If an application is running smoothly, // it shouldn't generate any error-level logs. ErrorLevel Level = zap.ErrorLevel // FatalLevel logs a message, then calls os.Exit(1). FatalLevel Level = zap.FatalLevel )
type Log ¶
type Log struct {
// contains filtered or unexported fields
}
Log wraps zap logger
func (*Log) Debug ¶
Debug logs a message at DebugLevel. The message includes any fields passed at the log site, as well as any fields accumulated on the logger.
func (*Log) Error ¶
Error logs a message at ErrorLevel. The message includes any fields passed at the log site, as well as any fields accumulated on the logger.
func (*Log) Fatal ¶
Fatal logs a message at FatalLevel. The message includes any fields passed at the log site, as well as any fields accumulated on the logger.
type Option ¶
type Option func(*Options)
Option define a func wraps Options
func WithEncoding ¶
WithEncoding specify the format of output, "json" and "console" are supported
func WithFileWriter ¶
func WithFileWriter(options ...FileOption) Option
WithFileWriter support write log to local file, with the FileOption configures
func WithLevelString ¶
withLevelString convert the level to Level type, if not exists, we set it as InfoLevel default
func WithWriter ¶
WithWriter specify the writer where log to write
type Options ¶
type Options struct {
// contains filtered or unexported fields
}
Options define some options for building a Log
type SugaredLogger ¶
type SugaredLogger = zap.SugaredLogger
Sugaredlogger is alias of zap.Sugaredlogger