Documentation ¶
Overview ¶
Package log contains the logging functions used by protosync.
Index ¶
- Variables
- func Configure(config Config) error
- func Debugf(format string, args ...interface{})
- func Elapsed(log *Logger, message string, args ...interface{}) func()
- func Errorf(format string, args ...interface{})
- func Fatalf(format string, args ...interface{})
- func Infof(format string, args ...interface{})
- func Logf(level Level, format string, args ...interface{})
- func Tracef(format string, args ...interface{})
- func Warnf(format string, args ...interface{})
- type Config
- type Level
- type Logger
- func (l *Logger) Debugf(format string, args ...interface{})
- func (l *Logger) Errorf(format string, args ...interface{})
- func (l *Logger) Fatalf(format string, args ...interface{})
- func (l *Logger) Infof(format string, args ...interface{})
- func (l *Logger) Logf(level Level, format string, args ...interface{})
- func (l *Logger) SubLogger(id string) *Logger
- func (l *Logger) Tracef(format string, args ...interface{})
- func (l *Logger) Warnf(format string, args ...interface{})
- func (l *Logger) Write(b []byte) (int, error)
- type WriterFlusher
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // Levels of logging. Levels = []Level{LevelTrace, LevelDebug, LevelInfo, LevelWarn, LevelError} // MinLevel of displayed logs. MinLevel = LevelWarn // LogOutput is the stdout for logs. LogOutput WriterFlusher = os.Stdout // LogError is the stderr for logs and where error+fatal logs are sent. LogError WriterFlusher = os.Stderr // Root logger. Root = &Logger{} )
Functions ¶
func Elapsed ¶
Elapsed logs the duration of a function call. Use with defer:
defer Elapsed(log, "something")()
func Fatalf ¶
func Fatalf(format string, args ...interface{})
Fatalf logs an error and terminates the process.
Types ¶
type Config ¶
type Config struct {
Level Level `help:"Minimum log level." default:"info"`
}
Config for logger.
type Level ¶
type Level int
Level for a log message.
const ( LevelTrace Level = iota // trace LevelDebug // debug LevelInfo // info LevelWarn // warn LevelError // error LevelFatal // fatal )
Log levels.
func LevelFromString ¶
LevelFromString maps a level to a string.
func (*Level) UnmarshalText ¶
type Logger ¶
type Logger struct {
// contains filtered or unexported fields
}
Logger is a scoped logging object.
type WriterFlusher ¶
WriterFlusher is used to flush log output after each line.
Click to show internal directories.
Click to hide internal directories.