Categorygithub.com/shipengqi/log
modulepackage
0.2.3
Repository: https://github.com/shipengqi/log.git
Documentation: pkg.go.dev

# README

log

A structured logger for Go, based on zap. Migrated from golib.

test codecov Go Report Card release license

Quick Start

opts := log.Newoptions()
errs := opts.Validate()
if len(errs) > 0 {
	// handle errors
	return
}

log.Configure(opts)
defer func() {
    _ = log.Close()
}()

log.Debug("debug message")
log.Info("info message")
log.Warn("warn message")
log.Error("error message")

log.Debugf("%s message", "debug")
log.Infof("%s message", "info")
log.Warnf("%s message", "warn")
log.Errorf("%s message", "error")

log.Debugt("debug message", log.String("key1", "value1"))
log.Infot("info message", log.Int32("key2", 10))
log.Warnt("warn message", log.Bool("key3", false))
log.Errort("error message", log.Any("key4", "any"))

Documentation

You can find the docs at go docs.

🔋 JetBrains OS licenses

log had been being developed with GoLand under the free JetBrains Open Source license(s) granted by JetBrains s.r.o., hence I would like to express my thanks here.

JetBrains Logo (Main) logo.

# Functions

AtLevel logs a message at Level.
AtLevelf logs a message at Level.
AtLevelt logs a message at Level.
Check returns a CheckedEntry if logging a message at the specified level is enabled.
Close implements io.Closer, and closes the current logfile of default logger.
Configure sets up the global logger.
Debug logs a message at DebugLevel.
Debugf logs a message at DebugLevel.
Debugt logs a message at DebugLevel.
DefaultFilenameEncoder return <process name>-<date>.log.
No description provided by the author
EncodedFilename returns the filename for logging when DisableFile is false.
Error logs a message at ErrorLevel.
Errorf logs a message at ErrorLevel.
Errort logs a message at ErrorLevel.
Fatal logs a message with some additional context, then calls os.Exit.
Fatalf uses fmt.Sprintf to log a templated message, then calls os.Exit.
Fatalt logs a message at FatalLevel, then calls os.Exit(1).
Flush calls the underlying Core's Sync method, flushing any buffered log entries.
Info logs a message at InfoLevel.
Infof logs a message at InfoLevel.
Infot logs a message at InfoLevel.
L returns the global logger.
New creates a new Logger.
NewOptions creates an Options with default parameters.
Panic logs a message with some additional context, then panics.
Panicf uses fmt.Sprintf to log a templated message, then panics.
Panict logs a message at PanicLevel, then panics.
Print logs a message at level Print.
Printf logs a message at level Print.
Println logs a message at level Print.
StdLogger returns logger of standard library which writes to supplied zap logger at the given level.
SugaredL returns global sugared logger.
Warn logs a message at WarnLevel.
Warnf logs a message at WarnLevel.
Warnt logs a message at WarnLevel.
WithValues creates a child logger and adds some Field of context to this logger.

# Constants

No description provided by the author

# Variables

Alias for zap type functions.
Alias for zap type functions.
Alias for zap type functions.
Alias for zap type functions.
Alias for zap type functions.
Alias for zap type functions.
Alias for zap type functions.
Alias for zap type functions.
Alias for zap type functions.
Alias for zap type functions.
Alias for zap type functions.
DebugLevel logs are typically voluminous, and are usually disabled in production.
DPanicLevel logs are particularly important errors.
Alias for zap type functions.
Alias for zap type functions.
Alias for zap type functions.
ErrorLevel logs are high-priority.
Alias for zap type functions.
FatalLevel logs a message, then calls os.Exit(1).
Alias for zap type functions.
Alias for zap type functions.
Alias for zap type functions.
Alias for zap type functions.
InfoLevel is the default logging priority.
Alias for zap type functions.
Alias for zap type functions.
Alias for zap type functions.
Alias for zap type functions.
Alias for zap type functions.
Alias for zap type functions.
Alias for zap type functions.
Alias for zap type functions.
Alias for zap type functions.
Alias for zap type functions.
Alias for zap type functions.
Alias for zap type functions.
PanicLevel logs a message, then panics.
Alias for zap type functions.
Alias for zap type functions.
Alias for zap type functions.
Alias for zap type functions.
Alias for zap type functions.
Alias for zap type functions.
Alias for zap type functions.
Alias for zap type functions.
Alias for zap type functions.
Alias for zap type functions.
Alias for zap type functions.
Alias for zap type functions.
Alias for zap type functions.
Alias for zap type functions.
Alias for zap type functions.
Alias for zap type functions.
Alias for zap type functions.
Alias for zap type functions.
Alias for zap type functions.
WarnLevel logs are more important than Info, but don't need individual human review.

# Structs

No description provided by the author
Options Configuration for logging.

# Interfaces

No description provided by the author
No description provided by the author
No description provided by the author

# Type aliases

CallerEncoder is an alias for the zapcore.CallerEncoder.
CheckedEntry is an alias for the zapcore.CheckedEntry.
Field is an alias for the zapcore.Field.
FilenameEncoder log filename encoder, return the full name of the log file.
Level is an alias for the zapcore.Level.
LevelEncoder is an alias for the zapcore.LevelEncoder.
TimeEncoder is an alias for the zapcore.TimeEncoder.