Documentation ¶
Index ¶
- Variables
- func Configure(cfg Config) error
- func Critical(format string, v ...interface{})
- func Debug(selector string, format string, v ...interface{})
- func DevelopmentSetup(options ...Option) error
- func Err(format string, v ...interface{})
- func HasSelector(selector string) bool
- func Info(format string, v ...interface{})
- func IsDebug(selector string) bool
- func MakeDebug(selector string) func(string, ...interface{})
- func ObserverLogs() *observer.ObservedLogs
- func Recover(msg string)
- func Sync() error
- func TestingSetup(options ...Option) error
- func WTF(format string, v ...interface{})deprecated
- func Warn(format string, v ...interface{})
- type Config
- type FileConfig
- type Level
- type LogOption
- type Logger
- func (l *Logger) DPanic(args ...interface{})
- func (l *Logger) DPanicf(format string, args ...interface{})
- func (l *Logger) DPanicw(msg string, keysAndValues ...interface{})
- func (l *Logger) Debug(args ...interface{})
- func (l *Logger) Debugf(format string, args ...interface{})
- func (l *Logger) Debugw(msg string, keysAndValues ...interface{})
- func (l *Logger) Error(args ...interface{})
- func (l *Logger) Errorf(format string, args ...interface{})
- func (l *Logger) Errorw(msg string, keysAndValues ...interface{})
- func (l *Logger) Info(args ...interface{})
- func (l *Logger) Infof(format string, args ...interface{})
- func (l *Logger) Infow(msg string, keysAndValues ...interface{})
- func (l *Logger) Panic(args ...interface{})
- func (l *Logger) Panicf(format string, args ...interface{})
- func (l *Logger) Panicw(msg string, keysAndValues ...interface{})
- func (l *Logger) Warn(args ...interface{})
- func (l *Logger) Warnf(format string, args ...interface{})
- func (l *Logger) Warnw(msg string, keysAndValues ...interface{})
- func (l *Logger) With(args ...interface{}) *Logger
- type Option
Constants ¶
This section is empty.
Variables ¶
var ( Any = zap.Any Array = zap.Array Binary = zap.Binary Bool = zap.Bool Bools = zap.Bools ByteString = zap.ByteString ByteStrings = zap.ByteStrings Complex64 = zap.Complex64 Complex64s = zap.Complex64s Complex128 = zap.Complex128 Complex128s = zap.Complex128s Duration = zap.Duration Durations = zap.Durations Error = zap.Error Errors = zap.Errors Float32 = zap.Float32 Float32s = zap.Float32s Float64 = zap.Float64 Float64s = zap.Float64s Int = zap.Int Ints = zap.Ints Int8 = zap.Int8 Int8s = zap.Int8s Int16 = zap.Int16 Int16s = zap.Int16s Int32 = zap.Int32 Int32s = zap.Int32s Int64 = zap.Int64 Int64s = zap.Int64s Namespace = zap.Namespace Reflect = zap.Reflect Stack = zap.Stack String = zap.String Stringer = zap.Stringer Strings = zap.Strings Time = zap.Time Times = zap.Times Uint = zap.Uint Uints = zap.Uints Uint8 = zap.Uint8 Uint8s = zap.Uint8s Uint16 = zap.Uint16 Uint16s = zap.Uint16s Uint32 = zap.Uint32 Uint32s = zap.Uint32s Uint64 = zap.Uint64 Uint64s = zap.Uint64s Uintptr = zap.Uintptr Uintptrs = zap.Uintptrs )
Field types for structured logging. Most fields are lazily marshaled so it is inexpensive to add fields to disabled log statements.
Functions ¶
func Critical ¶
func Critical(format string, v ...interface{})
Critical uses fmt.Sprintf to construct and log a message. It's an alias for Error. Deprecated: Use logp.NewLogger.
func DevelopmentSetup ¶
DevelopmentSetup configures the logger in development mode at debug level. By default the output goes to stderr.
func Err ¶
func Err(format string, v ...interface{})
Err uses fmt.Sprintf to construct and log a message. Deprecated: Use logp.NewLogger.
func HasSelector ¶
HasSelector returns true if the given selector was explicitly set.
func Info ¶
func Info(format string, v ...interface{})
Info uses fmt.Sprintf to construct and log a message. Deprecated: Use logp.NewLogger.
func IsDebug ¶
IsDebug returns true if the given selector would be logged. Deprecated: Use logp.NewLogger.
func MakeDebug ¶
MakeDebug returns a function that logs at debug level. Deprecated: Use logp.NewLogger.
func ObserverLogs ¶
func ObserverLogs() *observer.ObservedLogs
ObserverLogs provides the list of logs generated during the observation process.
func Sync ¶
func Sync() error
Sync flushes any buffered log entries. Applications should take care to call Sync before exiting.
func TestingSetup ¶
TestingSetup configures logging by calling DevelopmentSetup if and only if verbose testing is enabled (as in 'go test -v').
Types ¶
type Config ¶
type Config struct { Beat string `config:",ignore"` // Name of the Beat (for default file name). JSON bool `config:"json"` // Write logs as JSON. Level Level `config:"level"` // Logging level (error, warning, info, debug). Selectors []string `config:"selectors"` // Selectors for debug level logging. ToStderr bool `config:"to_stderr"` ToSyslog bool `config:"to_syslog"` ToFiles bool `config:"to_files"` ToEventLog bool `config:"to_eventlog"` Files FileConfig `config:"files"` // contains filtered or unexported fields }
Config contains the configuration options for the logger. To create a Config from a common.Config use logp/config.Build.
type FileConfig ¶
type FileConfig struct { Path string `config:"path"` Name string `config:"name"` MaxSize uint `config:"rotateeverybytes" validate:"min=1"` MaxBackups uint `config:"keepfiles" validate:"max=1024"` Permissions uint32 `config:"permissions"` }
FileConfig contains the configuration options for the file output.
type Level ¶
type Level int8
Level is a logging priority. Higher levels are more important.
const ( DebugLevel Level = iota - 1 InfoLevel WarnLevel ErrorLevel CriticalLevel // Critical exists only for config backward compatibility. )
Logging levels.
type Logger ¶
type Logger struct {
// contains filtered or unexported fields
}
Logger logs messages to the configured output.
func NewLogger ¶
NewLogger returns a new Logger labeled with the name of the selector. This should never be used from any global contexts (instead create "per instance" loggers).
func (*Logger) DPanic ¶
func (l *Logger) DPanic(args ...interface{})
DPanic uses fmt.Sprint to construct and log a message. In development, the logger then panics.
func (*Logger) DPanicf ¶
DPanicf uses fmt.Sprintf to log a templated message. In development, the logger then panics.
func (*Logger) DPanicw ¶
DPanicw logs a message with some additional context. The logger panics only in Development mode. The additional context is added in the form of key-value pairs. The optimal way to write the value to the log message will be inferred by the value's type. To explicitly specify a type you can pass a Field such as logp.Stringer.
func (*Logger) Debug ¶
func (l *Logger) Debug(args ...interface{})
Debug uses fmt.Sprint to construct and log a message.
func (*Logger) Debugw ¶
Debugw logs a message with some additional context. The additional context is added in the form of key-value pairs. The optimal way to write the value to the log message will be inferred by the value's type. To explicitly specify a type you can pass a Field such as logp.Stringer.
func (*Logger) Error ¶
func (l *Logger) Error(args ...interface{})
Error uses fmt.Sprint to construct and log a message.
func (*Logger) Errorw ¶
Errorw logs a message with some additional context. The additional context is added in the form of key-value pairs. The optimal way to write the value to the log message will be inferred by the value's type. To explicitly specify a type you can pass a Field such as logp.Stringer.
func (*Logger) Info ¶
func (l *Logger) Info(args ...interface{})
Info uses fmt.Sprint to construct and log a message.
func (*Logger) Infow ¶
Infow logs a message with some additional context. The additional context is added in the form of key-value pairs. The optimal way to write the value to the log message will be inferred by the value's type. To explicitly specify a type you can pass a Field such as logp.Stringer.
func (*Logger) Panic ¶
func (l *Logger) Panic(args ...interface{})
Panic uses fmt.Sprint to construct and log a message, then panics.
func (*Logger) Panicw ¶
Panicw logs a message with some additional context, then panics. The additional context is added in the form of key-value pairs. The optimal way to write the value to the log message will be inferred by the value's type. To explicitly specify a type you can pass a Field such as logp.Stringer.
func (*Logger) Warn ¶
func (l *Logger) Warn(args ...interface{})
Warn uses fmt.Sprint to construct and log a message.
func (*Logger) Warnw ¶
Warnw logs a message with some additional context. The additional context is added in the form of key-value pairs. The optimal way to write the value to the log message will be inferred by the value's type. To explicitly specify a type you can pass a Field such as logp.Stringer.
type Option ¶
type Option func(cfg *Config)
Option configures the logp package behavior.
func ToDiscardOutput ¶
func ToDiscardOutput() Option
ToDiscardOutput configures the logger to write to io.Discard. This is for benchmarking purposes only.
func ToObserverOutput ¶
func ToObserverOutput() Option
ToObserverOutput specifies that the output should be collected in memory so that they can be read by an observer by calling ObserverLogs().
func WithSelectors ¶
WithSelectors specifies what debug selectors are enabled. If no selectors are specified then they are all enabled.