Documentation ¶
Index ¶
- Constants
- Variables
- func Close(ctx context.Context) error
- func Drain()
- func DrainContext(ctx context.Context) error
- func SetLogName(p string) (err error)
- func SetStdErr()
- func SetStdOut()
- func SetTee(tee chan string)
- func Stats() (logs, pending, drop, errs uint64)
- type Level
- type Logger
- func (l *Logger) Debug(prefix, format string, v ...interface{})
- func (l *Logger) Debugf(prefix, format string, v ...interface{})
- func (l *Logger) Error(prefix, format string, v ...interface{})
- func (l *Logger) Errorf(prefix, format string, v ...interface{})
- func (l *Logger) Info(prefix, format string, v ...interface{})
- func (l *Logger) Infof(prefix, format string, v ...interface{})
- func (l *Logger) Level() Level
- func (l *Logger) Panic(prefix, format string, v ...interface{})
- func (l *Logger) Panicf(prefix, format string, v ...interface{})
- func (l *Logger) Printf(level Level, prefix, format string, v ...interface{})
- func (l *Logger) SetAccessLogSample(sample uint64)
- func (l *Logger) SetLevel(level Level)
- func (l *Logger) Warn(prefix, format string, v ...interface{})
- func (l *Logger) Warnf(prefix, format string, v ...interface{})
- func (l *Logger) Write(p []byte) (int, error)
Constants ¶
const ( NumMessages = 10 * 1024 // number of allowed log messages STDOUT_FORMAT = "2006-01-02T15:04:05.000 " LOG_INFO = 2 LOG_DEBUG = 1 LOG_ERR = 4 LOG_WARNING = 3 )
Variables ¶
var ( // offLogger is a dummy no-op logger. OffLogger = New(Levels.Off) // Levels is a singleton that represents possible log levels. Levels = struct { Off Level Panic Level Error Level Warn Level Info Level Debug Level Access Level }{ Access: (-1), Off: (0), Panic: (1), Error: (2), Warn: (3), Info: (4), Debug: (5), } // CfgLevels maps strings to Level. The intent is to use this during config // time. CfgLevels = map[string]Level{ "access": Levels.Access, "off": Levels.Off, "panic": Levels.Panic, "error": Levels.Error, "warn": Levels.Warn, "info": Levels.Info, "debug": Levels.Debug, } )
Functions ¶
func Close ¶
Close shuts down the logger system. After Close is called, any additional logs will panic. Only call this if you are completely done.
func Drain ¶
func Drain()
Drain is like DrainContext, but you didn't want to write context.Background(). Outside of tests, you want to use DrainContext.
func DrainContext ¶
DrainContext blocks until it sees no pending messages or the context is canceled. Pending messages may never run out if another goroutine is constantly writing.
func SetLogName ¶
SetLogName sets the indentifier used by syslog for this program
func Stats ¶
func Stats() (logs, pending, drop, errs uint64)
Stats returns the current status of the logger. It reports: * logs: number of logs attempted to be written since startup * pending: number of logs queued to be written * drop: numer of logs that have been dropped, because the write queue is full, since startup * errs: number of errors seen while trying to write logs since startup
Types ¶
type Logger ¶
type Logger struct {
// contains filtered or unexported fields
}