Documentation ¶
Index ¶
- Constants
- Variables
- func Fastrandn(x uint32) uint32
- func Goid() int64
- func IsTerminal(fd uintptr) bool
- func Printf(format string, v ...interface{})
- type AsyncWriter
- type ConsoleWriter
- type Context
- type Entry
- func (e *Entry) AnErr(key string, err error) *Entry
- func (e *Entry) Bool(key string, b bool) *Entry
- func (e *Entry) Bools(key string, b []bool) *Entry
- func (e *Entry) Byte(key string, val byte) *Entry
- func (e *Entry) Bytes(key string, val []byte) *Entry
- func (e *Entry) BytesOrNil(key string, val []byte) *Entry
- func (e *Entry) Caller(depth int) *Entry
- func (e *Entry) Context(ctx Context) *Entry
- func (e *Entry) Dict(key string, ctx Context) *Entry
- func (e *Entry) Discard() *Entry
- func (e *Entry) Dur(key string, d time.Duration) *Entry
- func (e *Entry) Durs(key string, d []time.Duration) *Entry
- func (e *Entry) Enabled() bool
- func (e *Entry) Err(err error) *Entry
- func (e *Entry) Errs(key string, errs []error) *Entry
- func (e *Entry) Fields(fields map[string]interface{}) *Entry
- func (e *Entry) Float32(key string, f float32) *Entry
- func (e *Entry) Float64(key string, f float64) *Entry
- func (e *Entry) Floats32(key string, f []float32) *Entry
- func (e *Entry) Floats64(key string, f []float64) *Entry
- func (e *Entry) GoStringer(key string, val fmt.GoStringer) *Entry
- func (e *Entry) Hex(key string, val []byte) *Entry
- func (e *Entry) IPAddr(key string, ip net.IP) *Entry
- func (e *Entry) IPPrefix(key string, pfx net.IPNet) *Entry
- func (e *Entry) Int(key string, i int) *Entry
- func (e *Entry) Int16(key string, i int16) *Entry
- func (e *Entry) Int32(key string, i int32) *Entry
- func (e *Entry) Int64(key string, i int64) *Entry
- func (e *Entry) Int8(key string, i int8) *Entry
- func (e *Entry) Interface(key string, i interface{}) *Entry
- func (e *Entry) MACAddr(key string, ha net.HardwareAddr) *Entry
- func (e *Entry) Msg(msg string)
- func (e *Entry) Msgf(format string, v ...interface{})
- func (e *Entry) RawJSON(key string, b []byte) *Entry
- func (e *Entry) RawJSONStr(key string, s string) *Entry
- func (e *Entry) Stack() *Entry
- func (e *Entry) Str(key string, val string) *Entry
- func (e *Entry) Stringer(key string, val fmt.Stringer) *Entry
- func (e *Entry) Strs(key string, vals []string) *Entry
- func (e *Entry) Time(key string, t time.Time) *Entry
- func (e *Entry) TimeDiff(key string, t time.Time, start time.Time) *Entry
- func (e *Entry) TimeFormat(key string, timefmt string, t time.Time) *Entry
- func (e *Entry) Uint16(key string, i uint16) *Entry
- func (e *Entry) Uint32(key string, i uint32) *Entry
- func (e *Entry) Uint64(key string, i uint64) *Entry
- func (e *Entry) Uint8(key string, i uint8) *Entry
- func (e *Entry) Value() Context
- func (e *Entry) Xid(key string, xid [12]byte) *Entry
- type Eventdeprecated
- type FileWriter
- type FormatterArgs
- type GrpcLogger
- func (g *GrpcLogger) Error(args ...interface{})
- func (g *GrpcLogger) Errorf(format string, args ...interface{})
- func (g *GrpcLogger) Errorln(args ...interface{})
- func (g *GrpcLogger) Fatal(args ...interface{})
- func (g *GrpcLogger) Fatalf(format string, args ...interface{})
- func (g *GrpcLogger) Fatalln(args ...interface{})
- func (g *GrpcLogger) Info(args ...interface{})
- func (g *GrpcLogger) Infof(format string, args ...interface{})
- func (g *GrpcLogger) Infoln(args ...interface{})
- func (g *GrpcLogger) V(level int) bool
- func (g *GrpcLogger) Warning(args ...interface{})
- func (g *GrpcLogger) Warningf(format string, args ...interface{})
- func (g *GrpcLogger) Warningln(args ...interface{})
- type IOWriter
- type JournalWriter
- type Level
- type Logger
- func (l *Logger) Debug() (e *Entry)
- func (l *Logger) Error() (e *Entry)
- func (l *Logger) Fatal() (e *Entry)
- func (l *Logger) Grpc(context Context) (g *GrpcLogger)
- func (l *Logger) Info() (e *Entry)
- func (l *Logger) Log() (e *Entry)
- func (l *Logger) Logr(context Context) *LogrLogger
- func (l *Logger) Panic() (e *Entry)
- func (l *Logger) Printf(format string, v ...interface{})
- func (l *Logger) SetLevel(level Level)
- func (l *Logger) Std(level Level, context Context, prefix string, flag int) *stdLog.Logger
- func (l *Logger) Sugar(context Context) (s *SugaredLogger)
- func (l *Logger) Trace() (e *Entry)
- func (l *Logger) Warn() (e *Entry)
- func (l *Logger) WithLevel(level Level) (e *Entry)
- type LogrLogger
- func (l *LogrLogger) Enabled() bool
- func (l *LogrLogger) Error(err error, msg string, keysAndValues ...interface{})
- func (l *LogrLogger) Info(msg string, keysAndValues ...interface{})
- func (l *LogrLogger) V(level int) *LogrLogger
- func (l *LogrLogger) WithName(name string) *LogrLogger
- func (l *LogrLogger) WithValues(keysAndValues ...interface{}) *LogrLogger
- type MultiWriter
- type SugaredLogger
- func (s *SugaredLogger) Debug(args ...interface{})
- func (s *SugaredLogger) Debugf(template string, args ...interface{})
- func (s *SugaredLogger) Debugw(msg string, keysAndValues ...interface{})
- func (s *SugaredLogger) Error(args ...interface{})
- func (s *SugaredLogger) Errorf(template string, args ...interface{})
- func (s *SugaredLogger) Errorw(msg string, keysAndValues ...interface{})
- func (s *SugaredLogger) Fatal(args ...interface{})
- func (s *SugaredLogger) Fatalf(template string, args ...interface{})
- func (s *SugaredLogger) Fatalw(msg string, keysAndValues ...interface{})
- func (s *SugaredLogger) Info(args ...interface{})
- func (s *SugaredLogger) Infof(template string, args ...interface{})
- func (s *SugaredLogger) Infow(msg string, keysAndValues ...interface{})
- func (s *SugaredLogger) Level(level Level) *SugaredLogger
- func (s *SugaredLogger) Log(keysAndValues ...interface{}) error
- func (s *SugaredLogger) Panic(args ...interface{})
- func (s *SugaredLogger) Panicf(template string, args ...interface{})
- func (s *SugaredLogger) Panicw(msg string, keysAndValues ...interface{})
- func (s *SugaredLogger) Print(args ...interface{})
- func (s *SugaredLogger) Printf(format string, args ...interface{})
- func (s *SugaredLogger) Println(args ...interface{})
- func (s *SugaredLogger) Warn(args ...interface{})
- func (s *SugaredLogger) Warnf(template string, args ...interface{})
- func (s *SugaredLogger) Warnw(msg string, keysAndValues ...interface{})
- type SyslogWriter
- type TSVEntry
- func (e *TSVEntry) Bool(b bool) *TSVEntry
- func (e *TSVEntry) Byte(b byte) *TSVEntry
- func (e *TSVEntry) Bytes(val []byte) *TSVEntry
- func (e *TSVEntry) Float32(f float32) *TSVEntry
- func (e *TSVEntry) Float64(f float64) *TSVEntry
- func (e *TSVEntry) IPAddr(ip net.IP) *TSVEntry
- func (e *TSVEntry) Int(i int) *TSVEntry
- func (e *TSVEntry) Int16(i int16) *TSVEntry
- func (e *TSVEntry) Int32(i int32) *TSVEntry
- func (e *TSVEntry) Int64(i int64) *TSVEntry
- func (e *TSVEntry) Int8(i int8) *TSVEntry
- func (e *TSVEntry) Msg()
- func (e *TSVEntry) Str(val string) *TSVEntry
- func (e *TSVEntry) Timestamp() *TSVEntry
- func (e *TSVEntry) TimestampMS() *TSVEntry
- func (e *TSVEntry) Uint16(i uint16) *TSVEntry
- func (e *TSVEntry) Uint32(i uint32) *TSVEntry
- func (e *TSVEntry) Uint64(i uint64) *TSVEntry
- func (e *TSVEntry) Uint8(i uint8) *TSVEntry
- type TSVLogger
- type Writer
Constants ¶
const ( // TimeFormatUnix defines a time format that makes time fields to be // serialized as Unix timestamp integers. TimeFormatUnix = "\x01" // TimeFormatUnixMs defines a time format that makes time fields to be // serialized as Unix timestamp integers in milliseconds. TimeFormatUnixMs = "\x02" )
Variables ¶
var DefaultLogger = Logger{ Level: DebugLevel, Caller: 0, TimeField: "", TimeFormat: "", Writer: IOWriter{os.Stderr}, }
DefaultLogger is the global logger.
Functions ¶
func Goid ¶ added in v1.0.29
func Goid() int64
Goid returns the current goroutine id. It exactly matches goroutine id of the stack trace.
func IsTerminal ¶
IsTerminal returns whether the given file descriptor is a terminal.
Types ¶
type AsyncWriter ¶ added in v1.0.37
type AsyncWriter struct { // ChannelSize is the size of the data channel, the default size is 1. ChannelSize uint // Writer specifies the writer of output. Writer Writer // contains filtered or unexported fields }
AsyncWriter is an Writer that writes asynchronously.
func (*AsyncWriter) Close ¶ added in v1.0.37
func (w *AsyncWriter) Close() (err error)
Close implements io.Closer, and closes the underlying Writer.
func (*AsyncWriter) WriteEntry ¶ added in v1.0.45
func (w *AsyncWriter) WriteEntry(e *Entry) (int, error)
WriteEntry implements Writer.
type ConsoleWriter ¶
type ConsoleWriter struct { // ColorOutput determines if used colorized output. ColorOutput bool // QuoteString determines if quoting string values. QuoteString bool // EndWithMessage determines if output message in the end. EndWithMessage bool // Formatter specifies an optional text formatter for creating a customized output, // If it is set, ColorOutput, QuoteString and EndWithMessage will be ignore. Formatter func(w io.Writer, args *FormatterArgs) (n int, err error) // Writer is the output destination. using os.Stderr if empty. Writer io.Writer }
ConsoleWriter parses the JSON input and writes it in an (optionally) colorized, human-friendly format to Writer.
Default output format:
{Time} {Level} {Goid} {Caller} > {Message} {Key}={Value} {Key}={Value}
Note: The performance of ConsoleWriter is not good enough, because it will parses JSON input into structured records, then output in a specific order. It's faster 2x than logrus.TextFormatter and 4x than zerolog.ConsoleWriter, but slower 0.5x than zap.ConsoleEncoder. Recommended for development scenarios.
func (*ConsoleWriter) Close ¶ added in v1.0.39
func (w *ConsoleWriter) Close() (err error)
Close implements io.Closer, will closes the underlying Writer if not empty.
func (*ConsoleWriter) Write ¶
func (w *ConsoleWriter) Write(p []byte) (int, error)
Write implements io.Writer
func (*ConsoleWriter) WriteEntry ¶ added in v1.0.46
func (w *ConsoleWriter) WriteEntry(e *Entry) (int, error)
WriteEntry implements Writer.
type Entry ¶ added in v1.0.45
type Entry struct { Level Level // contains filtered or unexported fields }
Entry represents a log entry. It is instanced by one of the level method of Logger and finalized by the Msg or Msgf method.
func NewContext ¶ added in v1.0.20
NewContext starts a new contextual entry.
func (*Entry) AnErr ¶ added in v1.0.45
AnErr adds the field key with serialized err to the logger context.
func (*Entry) BytesOrNil ¶ added in v1.0.45
BytesOrNil adds the field key with val as a string or nil to the entry.
func (*Entry) Durs ¶ added in v1.0.45
Durs adds the field key with val as a []time.Duration to the entry.
func (*Entry) Enabled ¶ added in v1.0.45
Enabled return false if the entry is going to be filtered out by log level.
func (*Entry) Errs ¶ added in v1.0.45
Errs adds the field key with errs as an array of serialized errors to the entry.
func (*Entry) Fields ¶ added in v1.0.45
Fields is a helper function to use a map to set fields using type assertion.
func (*Entry) Float32 ¶ added in v1.0.45
Float32 adds the field key with f as a float32 to the entry.
func (*Entry) Float64 ¶ added in v1.0.45
Float64 adds the field key with f as a float64 to the entry.
func (*Entry) Floats32 ¶ added in v1.0.45
Floats32 adds the field key with f as a []float32 to the entry.
func (*Entry) Floats64 ¶ added in v1.0.45
Floats64 adds the field key with f as a []float64 to the entry.
func (*Entry) GoStringer ¶ added in v1.0.45
func (e *Entry) GoStringer(key string, val fmt.GoStringer) *Entry
GoStringer adds the field key with val.GoStringer() to the entry.
func (*Entry) IPPrefix ¶ added in v1.0.45
IPPrefix adds IPv4 or IPv6 Prefix (address and mask) to the entry.
func (*Entry) Interface ¶ added in v1.0.45
Interface adds the field key with i marshaled using reflection.
func (*Entry) MACAddr ¶ added in v1.0.45
func (e *Entry) MACAddr(key string, ha net.HardwareAddr) *Entry
MACAddr adds MAC address to the entry.
func (*Entry) Msg ¶ added in v1.0.45
Msg sends the entry with msg added as the message field if not empty.
func (*Entry) Msgf ¶ added in v1.0.45
Msgf sends the entry with formatted msg added as the message field if not empty.
func (*Entry) RawJSON ¶ added in v1.0.45
RawJSON adds already encoded JSON to the log line under key.
func (*Entry) RawJSONStr ¶ added in v1.0.45
RawJSONStr adds already encoded JSON String to the log line under key.
func (*Entry) Stack ¶ added in v1.0.45
Stack enables stack trace printing for the error passed to Err().
func (*Entry) Stringer ¶ added in v1.0.45
Stringer adds the field key with val.String() to the entry.
func (*Entry) Time ¶ added in v1.0.45
Time append append t formated as string using time.RFC3339Nano.
func (*Entry) TimeDiff ¶ added in v1.0.45
TimeDiff adds the field key with positive duration between time t and start. If time t is not greater than start, duration will be 0. Duration format follows the same principle as Dur().
func (*Entry) TimeFormat ¶ added in v1.0.45
TimeFormat append append t formated as string using timefmt.
type FileWriter ¶ added in v1.0.8
type FileWriter struct { // Filename is the file to write logs to. Backup log files will be retained // in the same directory. Filename string // MaxSize is the maximum size in bytes of the log file before it gets rotated. MaxSize int64 // MaxBackups is the maximum number of old log files to retain. The default // is to retain all old log files MaxBackups int // FileMode represents the file's mode and permission bits. The default // mode is 0644 FileMode os.FileMode // LocalTime determines if the time used for formatting the timestamps in // log files is the computer's local time. The default is to use UTC time. LocalTime bool // HostName determines if the hostname used for formatting in log files. HostName bool // ProcessID determines if the pid used for formatting in log files. ProcessID bool // contains filtered or unexported fields }
FileWriter is an Writer that writes to the specified filename.
Backups use the log file name given to FileWriter, in the form `name.timestamp.ext` where name is the filename without the extension, timestamp is the time at which the log was rotated formatted with the time.Time format of `2006-01-02T15-04-05` and the extension is the original extension. For example, if your FileWriter.Filename is `/var/log/foo/server.log`, a backup created at 6:30pm on Nov 11 2016 would use the filename `/var/log/foo/server.2016-11-04T18-30-00.log`
Cleaning Up Old Log Files ¶
Whenever a new logfile gets created, old log files may be deleted. The most recent files according to the encoded timestamp will be retained, up to a number equal to MaxBackups (or all of them if MaxBackups is 0). Any files with an encoded timestamp older than MaxAge days are deleted, regardless of MaxBackups. Note that the time encoded in the timestamp is the rotation time, which may differ from the last time that file was written to.
func (*FileWriter) Close ¶ added in v1.0.8
func (w *FileWriter) Close() (err error)
Close implements io.Closer, and closes the current logfile.
func (*FileWriter) Rotate ¶ added in v1.0.8
func (w *FileWriter) Rotate() (err error)
Rotate causes Logger to close the existing log file and immediately create a new one. This is a helper function for applications that want to initiate rotations outside of the normal rotation rules, such as in response to SIGHUP. After rotating, this initiates compression and removal of old log files according to the configuration.
func (*FileWriter) Write ¶ added in v1.0.8
func (w *FileWriter) Write(p []byte) (n int, err error)
Write implements io.Writer. If a write would cause the log file to be larger than MaxSize, the file is closed, renamed to include a timestamp of the current time, and a new log file is created using the original log file name. If the length of the write is greater than MaxSize, an error is returned.
func (*FileWriter) WriteEntry ¶ added in v1.0.46
func (w *FileWriter) WriteEntry(e *Entry) (n int, err error)
WriteEntry implements Writer. If a write would cause the log file to be larger than MaxSize, the file is closed, renamed to include a timestamp of the current time, and a new log file is created using the original log file name. If the length of the write is greater than MaxSize, an error is returned.
type FormatterArgs ¶ added in v1.0.46
type FormatterArgs struct { Time string // "2019-07-10T05:35:54.277Z" Level string // "info" Caller string // "prog.go:42" Goid string // "123" Message string // "a structure message" Stack string // "<stack string>" KeyValues []struct { Key string // "foo" Value string // "bar" } }
FormatterArgs is a parsed sturct from json input
type GrpcLogger ¶
type GrpcLogger struct {
// contains filtered or unexported fields
}
GrpcLogger implements methods to satisfy interface google.golang.org/grpc/grpclog.LoggerV2.
func (*GrpcLogger) Error ¶
func (g *GrpcLogger) Error(args ...interface{})
Error logs to ERROR log. Arguments are handled in the manner of fmt.Print.
func (*GrpcLogger) Errorf ¶
func (g *GrpcLogger) Errorf(format string, args ...interface{})
Errorf logs to ERROR log. Arguments are handled in the manner of fmt.Printf.
func (*GrpcLogger) Errorln ¶
func (g *GrpcLogger) Errorln(args ...interface{})
Errorln logs to ERROR log. Arguments are handled in the manner of fmt.Println.
func (*GrpcLogger) Fatal ¶
func (g *GrpcLogger) Fatal(args ...interface{})
Fatal logs to ERROR log. Arguments are handled in the manner of fmt.Print. gRPC ensures that all Fatal logs will exit with os.Exit(1). Implementations may also call os.Exit() with a non-zero exit code.
func (*GrpcLogger) Fatalf ¶
func (g *GrpcLogger) Fatalf(format string, args ...interface{})
Fatalf logs to ERROR log. Arguments are handled in the manner of fmt.Printf. gRPC ensures that all Fatal logs will exit with os.Exit(1). Implementations may also call os.Exit() with a non-zero exit code.
func (*GrpcLogger) Fatalln ¶
func (g *GrpcLogger) Fatalln(args ...interface{})
Fatalln logs to ERROR log. Arguments are handled in the manner of fmt.Println. gRPC ensures that all Fatal logs will exit with os.Exit(1). Implementations may also call os.Exit() with a non-zero exit code.
func (*GrpcLogger) Info ¶
func (g *GrpcLogger) Info(args ...interface{})
Info logs to INFO log. Arguments are handled in the manner of fmt.Print.
func (*GrpcLogger) Infof ¶
func (g *GrpcLogger) Infof(format string, args ...interface{})
Infof logs to INFO log. Arguments are handled in the manner of fmt.Printf.
func (*GrpcLogger) Infoln ¶
func (g *GrpcLogger) Infoln(args ...interface{})
Infoln logs to INFO log. Arguments are handled in the manner of fmt.Println.
func (*GrpcLogger) V ¶
func (g *GrpcLogger) V(level int) bool
V reports whether verbosity level l is at least the requested verbose leveg.
func (*GrpcLogger) Warning ¶
func (g *GrpcLogger) Warning(args ...interface{})
Warning logs to WARNING log. Arguments are handled in the manner of fmt.Print.
func (*GrpcLogger) Warningf ¶
func (g *GrpcLogger) Warningf(format string, args ...interface{})
Warningf logs to WARNING log. Arguments are handled in the manner of fmt.Printf.
func (*GrpcLogger) Warningln ¶
func (g *GrpcLogger) Warningln(args ...interface{})
Warningln logs to WARNING log. Arguments are handled in the manner of fmt.Println.
type JournalWriter ¶ added in v1.0.34
type JournalWriter struct { // JournalSocket specifies socket name, using `/run/systemd/journal/socket` if empty. JournalSocket string // contains filtered or unexported fields }
JournalWriter is an Writer that writes logs to journald.
func (*JournalWriter) Close ¶ added in v1.0.34
func (w *JournalWriter) Close() (err error)
Close implements io.Closer.
func (*JournalWriter) WriteEntry ¶ added in v1.0.46
func (w *JournalWriter) WriteEntry(e *Entry) (n int, err error)
WriteEntry implements Writer.
type Level ¶
type Level int32
Level defines log levels.
const ( // TraceLevel defines trace log level. TraceLevel Level = -1 // DebugLevel defines debug log level. DebugLevel Level = 0 // InfoLevel defines info log level. InfoLevel Level = 1 // WarnLevel defines warn log level. WarnLevel Level = 2 // ErrorLevel defines error log level. ErrorLevel Level = 3 // FatalLevel defines fatal log level. FatalLevel Level = 4 // PanicLevel defines panic log level. PanicLevel Level = 5 )
func ParseLevel ¶
ParseLevel converts a level string into a log Level value.
type Logger ¶
type Logger struct { // Level defines log levels. Level Level // Caller determines if adds the file:line of the "caller" key. Caller int // TimeField defines the time filed name in output. It uses "time" in if empty. TimeField string // TimeFormat specifies the time format in output. It uses time.RFC3389 in if empty. // If set with `TimeFormatUnix`, `TimeFormatUnixMs`, times are formated as UNIX timestamp. TimeFormat string // Writer specifies the writer of output. It uses os.Stderr in if empty. Writer Writer }
A Logger represents an active logging object that generates lines of JSON output to an io.Writer.
func (*Logger) Grpc ¶ added in v1.0.24
func (l *Logger) Grpc(context Context) (g *GrpcLogger)
Grpc wraps the Logger to provide a LoggerV2 logger
func (*Logger) Logr ¶ added in v1.0.31
func (l *Logger) Logr(context Context) *LogrLogger
Logr wraps the Logger to provide a logr logger
func (*Logger) Printf ¶
Printf sends a log entry without extra field. Arguments are handled in the manner of fmt.Printf.
func (*Logger) Sugar ¶ added in v1.0.23
func (l *Logger) Sugar(context Context) (s *SugaredLogger)
Sugar wraps the Logger to provide a more ergonomic, but a little bit slower, API. Sugaring a Logger is quite inexpensive, so it's reasonable for a single application to use both Loggers and SugaredLoggers, converting between them on the boundaries of performance-sensitive code.
type LogrLogger ¶ added in v1.0.31
type LogrLogger struct {
// contains filtered or unexported fields
}
LogrLogger implements methods to satisfy interface github.com/go-logr/logr.Logger.
func (*LogrLogger) Enabled ¶ added in v1.0.31
func (l *LogrLogger) Enabled() bool
Enabled tests whether this Logger is enabled. For example, commandline flags might be used to set the logging verbosity and disable some info logs.
func (*LogrLogger) Error ¶ added in v1.0.31
func (l *LogrLogger) Error(err error, msg string, keysAndValues ...interface{})
Error logs an error, with the given message and key/value pairs as context. It functions similarly to calling Info with the "error" named value, but may have unique behavior, and should be preferred for logging errors (see the package documentations for more information).
The msg field should be used to add context to any underlying error, while the err field should be used to attach the actual error that triggered this log line, if present.
func (*LogrLogger) Info ¶ added in v1.0.31
func (l *LogrLogger) Info(msg string, keysAndValues ...interface{})
Info logs a non-error message with the given key/value pairs as context.
The msg argument should be used to add some constant description to the log line. The key/value pairs can then be used to add additional variable information. The key/value pairs should alternate string keys and arbitrary values.
func (*LogrLogger) V ¶ added in v1.0.31
func (l *LogrLogger) V(level int) *LogrLogger
V returns an Logger value for a specific verbosity level, relative to this Logger. In other words, V values are additive. V higher verbosity level means a log message is less important. It's illegal to pass a log level less than zero.
func (*LogrLogger) WithName ¶ added in v1.0.31
func (l *LogrLogger) WithName(name string) *LogrLogger
WithName adds a new element to the logger's name. Successive calls with WithName continue to append suffixes to the logger's name. It's strongly recommended that name segments contain only letters, digits, and hyphens (see the package documentation for more information).
func (*LogrLogger) WithValues ¶ added in v1.0.31
func (l *LogrLogger) WithValues(keysAndValues ...interface{}) *LogrLogger
WithValues adds some key-value pairs of context to a logger. See Info for documentation on how key/value pairs work.
type MultiWriter ¶ added in v1.0.34
type MultiWriter struct { // InfoWriter specifies all the level logs writes to InfoWriter Writer // WarnWriter specifies the level greater than or equal to WarnLevel writes to WarnWriter Writer // WarnWriter specifies the level greater than or equal to ErrorLevel writes to ErrorWriter Writer // ConsoleWriter specifies the console writer ConsoleWriter Writer // ConsoleLevel specifies the level greater than or equal to it also writes to ConsoleLevel Level }
MultiWriter is an Writer that log to different writers by different levels
func (*MultiWriter) Close ¶ added in v1.0.34
func (w *MultiWriter) Close() (err error)
Close implements io.Closer, and closes the underlying LeveledWriter.
func (*MultiWriter) WriteEntry ¶ added in v1.0.45
func (w *MultiWriter) WriteEntry(e *Entry) (n int, err error)
WriteEntry implements entryWriter.
type SugaredLogger ¶ added in v1.0.23
type SugaredLogger struct {
// contains filtered or unexported fields
}
A SugaredLogger wraps the base Logger functionality in a slower, but less verbose, API. Any Logger can be converted to a SugaredLogger with its Sugar method.
Unlike the Logger, the SugaredLogger doesn't insist on structured logging. For each log level, it exposes three methods: one for loosely-typed structured logging, one for println-style formatting, and one for printf-style formatting.
func (*SugaredLogger) Debug ¶ added in v1.0.25
func (s *SugaredLogger) Debug(args ...interface{})
Debug uses fmt.Sprint to construct and log a message.
func (*SugaredLogger) Debugf ¶ added in v1.0.25
func (s *SugaredLogger) Debugf(template string, args ...interface{})
Debugf uses fmt.Sprintf to log a templated message.
func (*SugaredLogger) Debugw ¶ added in v1.0.25
func (s *SugaredLogger) Debugw(msg string, keysAndValues ...interface{})
Debugw logs a message with some additional context.
func (*SugaredLogger) Error ¶ added in v1.0.25
func (s *SugaredLogger) Error(args ...interface{})
Error uses fmt.Sprint to construct and log a message.
func (*SugaredLogger) Errorf ¶ added in v1.0.25
func (s *SugaredLogger) Errorf(template string, args ...interface{})
Errorf uses fmt.Sprintf to log a templated message.
func (*SugaredLogger) Errorw ¶ added in v1.0.25
func (s *SugaredLogger) Errorw(msg string, keysAndValues ...interface{})
Errorw logs a message with some additional context.
func (*SugaredLogger) Fatal ¶ added in v1.0.25
func (s *SugaredLogger) Fatal(args ...interface{})
Fatal uses fmt.Sprint to construct and log a message.
func (*SugaredLogger) Fatalf ¶ added in v1.0.25
func (s *SugaredLogger) Fatalf(template string, args ...interface{})
Fatalf uses fmt.Sprintf to log a templated message.
func (*SugaredLogger) Fatalw ¶ added in v1.0.25
func (s *SugaredLogger) Fatalw(msg string, keysAndValues ...interface{})
Fatalw logs a message with some additional context.
func (*SugaredLogger) Info ¶ added in v1.0.25
func (s *SugaredLogger) Info(args ...interface{})
Info uses fmt.Sprint to construct and log a message.
func (*SugaredLogger) Infof ¶ added in v1.0.25
func (s *SugaredLogger) Infof(template string, args ...interface{})
Infof uses fmt.Sprintf to log a templated message.
func (*SugaredLogger) Infow ¶ added in v1.0.25
func (s *SugaredLogger) Infow(msg string, keysAndValues ...interface{})
Infow logs a message with some additional context.
func (*SugaredLogger) Level ¶ added in v1.0.25
func (s *SugaredLogger) Level(level Level) *SugaredLogger
Level creates a child logger with the minimum accepted level set to level.
func (*SugaredLogger) Log ¶ added in v1.0.23
func (s *SugaredLogger) Log(keysAndValues ...interface{}) error
Log sends a log entry with extra fields.
func (*SugaredLogger) Panic ¶ added in v1.0.29
func (s *SugaredLogger) Panic(args ...interface{})
Panic uses fmt.Sprint to construct and log a message.
func (*SugaredLogger) Panicf ¶ added in v1.0.29
func (s *SugaredLogger) Panicf(template string, args ...interface{})
Panicf uses fmt.Sprintf to log a templated message.
func (*SugaredLogger) Panicw ¶ added in v1.0.29
func (s *SugaredLogger) Panicw(msg string, keysAndValues ...interface{})
Panicw logs a message with some additional context.
func (*SugaredLogger) Print ¶ added in v1.0.23
func (s *SugaredLogger) Print(args ...interface{})
Print sends a log entry without extra field. Arguments are handled in the manner of fmt.Print.
func (*SugaredLogger) Printf ¶ added in v1.0.23
func (s *SugaredLogger) Printf(format string, args ...interface{})
Printf sends a log entry without extra field. Arguments are handled in the manner of fmt.Printf.
func (*SugaredLogger) Println ¶ added in v1.0.23
func (s *SugaredLogger) Println(args ...interface{})
Println sends a log entry without extra field. Arguments are handled in the manner of fmt.Print.
func (*SugaredLogger) Warn ¶ added in v1.0.25
func (s *SugaredLogger) Warn(args ...interface{})
Warn uses fmt.Sprint to construct and log a message.
func (*SugaredLogger) Warnf ¶ added in v1.0.25
func (s *SugaredLogger) Warnf(template string, args ...interface{})
Warnf uses fmt.Sprintf to log a templated message.
func (*SugaredLogger) Warnw ¶ added in v1.0.25
func (s *SugaredLogger) Warnw(msg string, keysAndValues ...interface{})
Warnw logs a message with some additional context.
type SyslogWriter ¶ added in v1.0.40
type SyslogWriter struct { // Network specifies network of the syslog server Network string // Address specifies address of the syslog server Address string // Hostname specifies hostname of the syslog message Hostname string // Tag specifies tag of the syslog message Tag string // Marker specifies prefix of the syslog message, e.g. `@cee:` Marker string // Dial specifies the dial function for creating TCP/TLS connections. Dial func(network, addr string) (net.Conn, error) // contains filtered or unexported fields }
SyslogWriter is an Writer that writes logs to a syslog server..
func (*SyslogWriter) Close ¶ added in v1.0.40
func (w *SyslogWriter) Close() (err error)
Close closes a connection to the syslog server.
func (*SyslogWriter) WriteEntry ¶ added in v1.0.46
func (w *SyslogWriter) WriteEntry(e *Entry) (n int, err error)
WriteEntry implements Writer, sends logs with priority to the syslog server.
type TSVEntry ¶ added in v1.0.45
type TSVEntry struct {
// contains filtered or unexported fields
}
TSVEntry represents a tsv log entry. It is instanced by one of TSVLogger and finalized by the Msg method.
func (*TSVEntry) TimestampMS ¶ added in v1.0.45
TimestampMS adds the current time with milliseconds as UNIX timestamp