Documentation ¶
Index ¶
- func ErrorWriter() io.Writer
- func FileExists(path string) (bool, error)
- func MakeParentDirs(filename string) error
- func NewContextWithLogTags(ctx context.Context, logTagsToAdd CtxLogTags) context.Context
- func OpenLogFile(filename string) (name string, file *os.File, err error)
- func OutputWriter() io.Writer
- func PickFirstError(errors ...error) error
- func SetLogFileConfig(lfc *LogFileConfig) error
- type CtxLogTags
- type CtxStandardLoggerKey
- type ExternalHandler
- type ExternalLogger
- type LogFileConfig
- type Logger
- type Loggerf
- type Null
- func (l *Null) CCriticalf(ctx context.Context, fmt string, arg ...interface{})
- func (l *Null) CDebugf(ctx context.Context, fmt string, arg ...interface{})
- func (l *Null) CErrorf(ctx context.Context, fmt string, arg ...interface{})
- func (l *Null) CFatalf(ctx context.Context, fmt string, arg ...interface{})
- func (l *Null) CInfof(ctx context.Context, fmt string, arg ...interface{})
- func (l *Null) CNoticef(ctx context.Context, fmt string, arg ...interface{})
- func (l *Null) CWarningf(ctx context.Context, fmt string, arg ...interface{})
- func (l *Null) CloneWithAddedDepth(depth int) Logger
- func (l *Null) Configure(style string, debug bool, filename string)
- func (l *Null) Critical(format string, args ...interface{})
- func (l *Null) Debug(format string, args ...interface{})
- func (l *Null) Error(fmt string, arg ...interface{})
- func (l *Null) Errorf(format string, args ...interface{})
- func (l *Null) Fatalf(fmt string, arg ...interface{})
- func (l *Null) Info(format string, args ...interface{})
- func (l *Null) Notice(format string, args ...interface{})
- func (l *Null) Profile(fmts string, arg ...interface{})
- func (l *Null) RotateLogFile() error
- func (l *Null) SetExternalHandler(handler ExternalHandler)
- func (l *Null) Shutdown()
- func (l *Null) Warning(format string, args ...interface{})
- type RPCLoggerAdapter
- func (l RPCLoggerAdapter) CCriticalf(_ context.Context, format string, args ...interface{})
- func (l RPCLoggerAdapter) CDebugf(_ context.Context, format string, args ...interface{})
- func (l RPCLoggerAdapter) CErrorf(_ context.Context, format string, args ...interface{})
- func (l RPCLoggerAdapter) CFatalf(_ context.Context, format string, args ...interface{})
- func (l RPCLoggerAdapter) CInfof(_ context.Context, format string, args ...interface{})
- func (l RPCLoggerAdapter) CNoticef(_ context.Context, format string, args ...interface{})
- func (l RPCLoggerAdapter) CWarningf(_ context.Context, format string, args ...interface{})
- func (l RPCLoggerAdapter) CloneWithAddedDepth(depth int) Logger
- func (l RPCLoggerAdapter) Configure(style string, debug bool, filename string)
- func (l RPCLoggerAdapter) Critical(format string, args ...interface{})
- func (l RPCLoggerAdapter) Debug(format string, args ...interface{})
- func (l RPCLoggerAdapter) Error(format string, args ...interface{})
- func (l RPCLoggerAdapter) Errorf(format string, args ...interface{})
- func (l RPCLoggerAdapter) Fatalf(format string, args ...interface{})
- func (l RPCLoggerAdapter) Info(format string, args ...interface{})
- func (l RPCLoggerAdapter) Notice(format string, args ...interface{})
- func (l RPCLoggerAdapter) Profile(format string, args ...interface{})
- func (l RPCLoggerAdapter) RotateLogFile() error
- func (l RPCLoggerAdapter) SetExternalHandler(handler ExternalHandler)
- func (l RPCLoggerAdapter) Warning(format string, args ...interface{})
- type Standard
- func (log *Standard) CCriticalf(ctx context.Context, fmt string, arg ...interface{})
- func (log *Standard) CDebugf(ctx context.Context, fmt string, arg ...interface{})
- func (log *Standard) CErrorf(ctx context.Context, fmt string, arg ...interface{})
- func (log *Standard) CFatalf(ctx context.Context, fmt string, arg ...interface{})
- func (log *Standard) CInfof(ctx context.Context, fmt string, arg ...interface{})
- func (log *Standard) CNoticef(ctx context.Context, fmt string, arg ...interface{})
- func (log *Standard) CWarningf(ctx context.Context, fmt string, arg ...interface{})
- func (log *Standard) CloneWithAddedDepth(depth int) Logger
- func (log *Standard) Configure(style string, debug bool, filename string)
- func (log *Standard) Critical(fmt string, arg ...interface{})
- func (log *Standard) Debug(fmt string, arg ...interface{})
- func (log *Standard) Error(fmt string, arg ...interface{})
- func (log *Standard) Errorf(fmt string, arg ...interface{})
- func (log *Standard) Fatalf(fmt string, arg ...interface{})
- func (log *Standard) GetUnforwardedLogger() *UnforwardedLogger
- func (log *Standard) Info(fmt string, arg ...interface{})
- func (log *Standard) Notice(fmt string, arg ...interface{})
- func (log *Standard) Profile(fmts string, arg ...interface{})
- func (log *Standard) RotateLogFile() error
- func (log *Standard) SetExternalHandler(handler ExternalHandler)
- func (log *Standard) Warning(fmt string, arg ...interface{})
- type TestLogBackend
- type TestLogger
- func (log *TestLogger) CCriticalf(ctx context.Context, fmts string, arg ...interface{})
- func (log *TestLogger) CDebugf(ctx context.Context, fmts string, arg ...interface{})
- func (log *TestLogger) CErrorf(ctx context.Context, fmts string, arg ...interface{})
- func (log *TestLogger) CFatalf(ctx context.Context, fmts string, arg ...interface{})
- func (log *TestLogger) CInfof(ctx context.Context, fmts string, arg ...interface{})
- func (log *TestLogger) CNoticef(ctx context.Context, fmts string, arg ...interface{})
- func (log *TestLogger) CWarningf(ctx context.Context, fmts string, arg ...interface{})
- func (log *TestLogger) CloneWithAddedDepth(depth int) Logger
- func (log *TestLogger) Configure(style string, debug bool, filename string)
- func (log *TestLogger) Critical(fmts string, arg ...interface{})
- func (log *TestLogger) Debug(fmts string, arg ...interface{})
- func (log *TestLogger) Error(fmts string, arg ...interface{})
- func (log *TestLogger) Errorf(fmts string, arg ...interface{})
- func (log *TestLogger) Fatalf(fmts string, arg ...interface{})
- func (log *TestLogger) Info(fmts string, arg ...interface{})
- func (log *TestLogger) Notice(fmts string, arg ...interface{})
- func (log *TestLogger) Profile(fmts string, arg ...interface{})
- func (log *TestLogger) RotateLogFile() error
- func (log *TestLogger) SetExternalHandler(_ ExternalHandler)
- func (log *TestLogger) Warning(fmts string, arg ...interface{})
- type UnforwardedLogger
- func (log *UnforwardedLogger) Debug(s string, args ...interface{})
- func (log *UnforwardedLogger) Error(s string, args ...interface{})
- func (log *UnforwardedLogger) Errorf(s string, args ...interface{})
- func (log *UnforwardedLogger) Info(s string, args ...interface{})
- func (log *UnforwardedLogger) Profile(s string, args ...interface{})
- func (log *UnforwardedLogger) Warning(s string, args ...interface{})
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ErrorWriter ¶
func FileExists ¶
func MakeParentDirs ¶
func NewContextWithLogTags ¶
func NewContextWithLogTags( ctx context.Context, logTagsToAdd CtxLogTags) context.Context
NewContext returns a new Context that carries adds the given log tag mappings (context key -> display string).
func OutputWriter ¶
func PickFirstError ¶
func SetLogFileConfig ¶
func SetLogFileConfig(lfc *LogFileConfig) error
SetLogFileConfig sets the log file config to be used globally.
Types ¶
type CtxLogTags ¶
type CtxLogTags map[interface{}]string
func LogTagsFromContext ¶
func LogTagsFromContext(ctx context.Context) (CtxLogTags, bool)
LogTagsFromContext returns the log tags being passed along with the given context.
type CtxStandardLoggerKey ¶
type CtxStandardLoggerKey int
CtxStandardLoggerKey is a type defining context keys used by the Standard logger.
const ( // CtxLogTagsKey defines a context key that can associate with a map of // context keys (key -> descriptive-name), the mapped values of which should // be logged by a Standard logger if one of those keys is seen in a context // during a log call. CtxLogTagsKey CtxStandardLoggerKey = iota )
type ExternalHandler ¶
type ExternalLogger ¶
type LogFileConfig ¶
type LogFileConfig struct { // Path is the path of the log file to use Path string // MaxSize is the size of log file (in bytes) before rotation, 0 for infinite. MaxSize int64 // MaxAge is the duration before log rotation, zero value for infinite. MaxAge time.Duration // MaxKeepFiles is maximum number of log files for this service, older // files are deleted. MaxKeepFiles int }
LogFileConfig is the config structure for new style log files with rotation.
type Logger ¶
type Logger interface { // Debug logs a message at debug level, with formatting args. Debug(format string, args ...interface{}) // CDebugf logs a message at debug level, with a context and // formatting args. CDebugf(ctx context.Context, format string, args ...interface{}) // Info logs a message at info level, with formatting args. Info(format string, args ...interface{}) // CInfo logs a message at info level, with a context and formatting args. CInfof(ctx context.Context, format string, args ...interface{}) // Notice logs a message at notice level, with formatting args. Notice(format string, args ...interface{}) // CNoticef logs a message at notice level, with a context and // formatting args. CNoticef(ctx context.Context, format string, args ...interface{}) // Warning logs a message at warning level, with formatting args. Warning(format string, args ...interface{}) // CWarning logs a message at warning level, with a context and // formatting args. CWarningf(ctx context.Context, format string, args ...interface{}) // Error logs a message at error level, with formatting args Error(format string, args ...interface{}) // Errorf logs a message at error level, with formatting args. Errorf(format string, args ...interface{}) // CErrorf logs a message at error level, with a context and // formatting args. CErrorf(ctx context.Context, format string, args ...interface{}) // Critical logs a message at critical level, with formatting args. Critical(format string, args ...interface{}) // CCriticalf logs a message at critical level, with a context and // formatting args. CCriticalf(ctx context.Context, format string, args ...interface{}) // Fatalf logs a message at fatal level, with formatting args. Fatalf(format string, args ...interface{}) // Fatalf logs a message at fatal level, with a context and formatting args. CFatalf(ctx context.Context, format string, args ...interface{}) // Profile logs a profile message, with formatting args. Profile(fmts string, arg ...interface{}) // Configure sets the style, debug level, and filename of the // logger. Output isn't redirected to the file until // RotateLogFile is called for the first time. Configure(style string, debug bool, filename string) // RotateLogFile rotates the log file, if the underlying logger is // writing to a file. RotateLogFile() error // Returns a logger that is like the current one, except with // more logging depth added on. CloneWithAddedDepth(depth int) Logger // SetExternalHandler sets a handler that will be called with every log message. SetExternalHandler(handler ExternalHandler) }
func NewRPCLoggerAdapter ¶ added in v1.0.18
type Loggerf ¶ added in v1.0.17
type Loggerf interface { Debugf(s string, args ...interface{}) Infof(s string, args ...interface{}) Warningf(s string, args ...interface{}) Errorf(s string, args ...interface{}) }
Loggerf is a minimal log interface (using proper formatter style methods)
func NewLoggerf ¶ added in v1.0.17
func NewLoggerf(log loggerInternal) Loggerf
NewLoggerf adapts a logger
type Null ¶
type Null struct{}
func (*Null) CCriticalf ¶
func (*Null) CloneWithAddedDepth ¶ added in v1.0.16
func (*Null) RotateLogFile ¶
func (*Null) SetExternalHandler ¶
func (l *Null) SetExternalHandler(handler ExternalHandler)
type RPCLoggerAdapter ¶ added in v1.0.18
type RPCLoggerAdapter struct {
// contains filtered or unexported fields
}
RPCLoggerAdapter is used to turn a logger complying to the rpc.LogOutput interface into one that can be used as a logger.Logger
func (RPCLoggerAdapter) CCriticalf ¶ added in v1.0.18
func (l RPCLoggerAdapter) CCriticalf(_ context.Context, format string, args ...interface{})
func (RPCLoggerAdapter) CDebugf ¶ added in v1.0.18
func (l RPCLoggerAdapter) CDebugf(_ context.Context, format string, args ...interface{})
func (RPCLoggerAdapter) CErrorf ¶ added in v1.0.18
func (l RPCLoggerAdapter) CErrorf(_ context.Context, format string, args ...interface{})
func (RPCLoggerAdapter) CFatalf ¶ added in v1.0.18
func (l RPCLoggerAdapter) CFatalf(_ context.Context, format string, args ...interface{})
func (RPCLoggerAdapter) CInfof ¶ added in v1.0.18
func (l RPCLoggerAdapter) CInfof(_ context.Context, format string, args ...interface{})
func (RPCLoggerAdapter) CNoticef ¶ added in v1.0.18
func (l RPCLoggerAdapter) CNoticef(_ context.Context, format string, args ...interface{})
func (RPCLoggerAdapter) CWarningf ¶ added in v1.0.18
func (l RPCLoggerAdapter) CWarningf(_ context.Context, format string, args ...interface{})
func (RPCLoggerAdapter) CloneWithAddedDepth ¶ added in v1.0.18
func (l RPCLoggerAdapter) CloneWithAddedDepth(depth int) Logger
func (RPCLoggerAdapter) Configure ¶ added in v1.0.18
func (l RPCLoggerAdapter) Configure(style string, debug bool, filename string)
func (RPCLoggerAdapter) Critical ¶ added in v1.0.18
func (l RPCLoggerAdapter) Critical(format string, args ...interface{})
func (RPCLoggerAdapter) Debug ¶ added in v1.0.18
func (l RPCLoggerAdapter) Debug(format string, args ...interface{})
func (RPCLoggerAdapter) Error ¶ added in v1.0.18
func (l RPCLoggerAdapter) Error(format string, args ...interface{})
func (RPCLoggerAdapter) Errorf ¶ added in v1.0.18
func (l RPCLoggerAdapter) Errorf(format string, args ...interface{})
func (RPCLoggerAdapter) Fatalf ¶ added in v1.0.18
func (l RPCLoggerAdapter) Fatalf(format string, args ...interface{})
func (RPCLoggerAdapter) Info ¶ added in v1.0.18
func (l RPCLoggerAdapter) Info(format string, args ...interface{})
func (RPCLoggerAdapter) Notice ¶ added in v1.0.18
func (l RPCLoggerAdapter) Notice(format string, args ...interface{})
func (RPCLoggerAdapter) Profile ¶ added in v1.0.18
func (l RPCLoggerAdapter) Profile(format string, args ...interface{})
func (RPCLoggerAdapter) RotateLogFile ¶ added in v1.0.18
func (l RPCLoggerAdapter) RotateLogFile() error
func (RPCLoggerAdapter) SetExternalHandler ¶ added in v1.0.18
func (l RPCLoggerAdapter) SetExternalHandler(handler ExternalHandler)
func (RPCLoggerAdapter) Warning ¶ added in v1.0.18
func (l RPCLoggerAdapter) Warning(format string, args ...interface{})
type Standard ¶
type Standard struct {
// contains filtered or unexported fields
}
func NewWithCallDepth ¶
NewWithCallDepth creates a new Standard logger for module, and when printing file names and line numbers, it goes extraCallDepth up the stack from where logger was invoked.
func (*Standard) CCriticalf ¶
func (*Standard) CloneWithAddedDepth ¶ added in v1.0.16
func (*Standard) Configure ¶
Configure sets the style of the log file, whether debugging (verbose) is enabled and a filename. If a filename is provided here it will be used for logging straight away (this is a new feature). SetLogFileConfig provides a way to set the log file with more control on rotation.
func (*Standard) GetUnforwardedLogger ¶
func (log *Standard) GetUnforwardedLogger() *UnforwardedLogger
func (*Standard) RotateLogFile ¶
RotateLogFile is the old style of logging to a file. It uses a default config for log rotation and uses the filename set from .Configure.
func (*Standard) SetExternalHandler ¶
func (log *Standard) SetExternalHandler(handler ExternalHandler)
type TestLogBackend ¶
type TestLogBackend interface { Error(args ...interface{}) Errorf(format string, args ...interface{}) Fatal(args ...interface{}) Fatalf(format string, args ...interface{}) Log(args ...interface{}) Logf(format string, args ...interface{}) }
TestLogBackend is an interface for logging to a test object (i.e., a *testing.T). We define this in order to avoid pulling in the "testing" package in exported code.
type TestLogger ¶
type TestLogger struct {
// contains filtered or unexported fields
}
TestLogger is a Logger that writes to a TestLogBackend. All messages except Fatal are printed using Logf, to avoid failing a test that is trying to test an error condition. No context tags are logged.
func NewTestLogger ¶
func NewTestLogger(log TestLogBackend) *TestLogger
func (*TestLogger) CCriticalf ¶
func (log *TestLogger) CCriticalf(ctx context.Context, fmts string, arg ...interface{})
func (*TestLogger) CDebugf ¶
func (log *TestLogger) CDebugf(ctx context.Context, fmts string, arg ...interface{})
func (*TestLogger) CErrorf ¶
func (log *TestLogger) CErrorf(ctx context.Context, fmts string, arg ...interface{})
func (*TestLogger) CFatalf ¶
func (log *TestLogger) CFatalf(ctx context.Context, fmts string, arg ...interface{})
func (*TestLogger) CInfof ¶
func (log *TestLogger) CInfof(ctx context.Context, fmts string, arg ...interface{})
func (*TestLogger) CNoticef ¶
func (log *TestLogger) CNoticef(ctx context.Context, fmts string, arg ...interface{})
func (*TestLogger) CWarningf ¶
func (log *TestLogger) CWarningf(ctx context.Context, fmts string, arg ...interface{})
func (*TestLogger) CloneWithAddedDepth ¶ added in v1.0.16
func (log *TestLogger) CloneWithAddedDepth(depth int) Logger
func (*TestLogger) Configure ¶
func (log *TestLogger) Configure(style string, debug bool, filename string)
func (*TestLogger) Critical ¶
func (log *TestLogger) Critical(fmts string, arg ...interface{})
func (*TestLogger) Debug ¶
func (log *TestLogger) Debug(fmts string, arg ...interface{})
func (*TestLogger) Error ¶
func (log *TestLogger) Error(fmts string, arg ...interface{})
func (*TestLogger) Errorf ¶
func (log *TestLogger) Errorf(fmts string, arg ...interface{})
func (*TestLogger) Fatalf ¶
func (log *TestLogger) Fatalf(fmts string, arg ...interface{})
func (*TestLogger) Info ¶
func (log *TestLogger) Info(fmts string, arg ...interface{})
func (*TestLogger) Notice ¶
func (log *TestLogger) Notice(fmts string, arg ...interface{})
func (*TestLogger) Profile ¶
func (log *TestLogger) Profile(fmts string, arg ...interface{})
func (*TestLogger) RotateLogFile ¶
func (log *TestLogger) RotateLogFile() error
func (*TestLogger) SetExternalHandler ¶
func (log *TestLogger) SetExternalHandler(_ ExternalHandler)
no-op stubs to fulfill the Logger interface
func (*TestLogger) Warning ¶
func (log *TestLogger) Warning(fmts string, arg ...interface{})
type UnforwardedLogger ¶
type UnforwardedLogger Standard
func (*UnforwardedLogger) Debug ¶
func (log *UnforwardedLogger) Debug(s string, args ...interface{})
func (*UnforwardedLogger) Error ¶
func (log *UnforwardedLogger) Error(s string, args ...interface{})
func (*UnforwardedLogger) Errorf ¶
func (log *UnforwardedLogger) Errorf(s string, args ...interface{})
func (*UnforwardedLogger) Info ¶
func (log *UnforwardedLogger) Info(s string, args ...interface{})
func (*UnforwardedLogger) Profile ¶
func (log *UnforwardedLogger) Profile(s string, args ...interface{})
func (*UnforwardedLogger) Warning ¶
func (log *UnforwardedLogger) Warning(s string, args ...interface{})