Codebase list golang-github-go-kit-kit / run/dff50435-7a33-4f0c-bbdc-f455eb10d80a/main log / log.go
run/dff50435-7a33-4f0c-bbdc-f455eb10d80a/main

Tree @run/dff50435-7a33-4f0c-bbdc-f455eb10d80a/main (Download .tar.gz)

log.go @run/dff50435-7a33-4f0c-bbdc-f455eb10d80a/main

8650f26
 
801da84
 
 
d3553b5
d3c703c
 
 
651b069
ee7b7bb
801da84
f307245
de98c75
 
801da84
37e3bc0
ee7b7bb
0268ca8
 
d4d79f9
ee7b7bb
 
055e4ba
801da84
f307245
 
ee7b7bb
 
0268ca8
ee7b7bb
 
 
055e4ba
801da84
8a32db2
 
0268ca8
 
 
 
 
 
 
801da84
ee7b7bb
 
f307245
 
 
801da84
package log

import (
	"github.com/go-kit/log"
)

// Logger is the fundamental interface for all log operations. Log creates a
// log event from keyvals, a variadic sequence of alternating keys and values.
// Implementations must be safe for concurrent use by multiple goroutines. In
// particular, any implementation of Logger that appends to keyvals or
// modifies or retains any of its elements must make a copy first.
type Logger = log.Logger

// ErrMissingValue is appended to keyvals slices with odd length to substitute
// the missing value.
var ErrMissingValue = log.ErrMissingValue

// With returns a new contextual logger with keyvals prepended to those passed
// to calls to Log. If logger is also a contextual logger created by With,
// WithPrefix, or WithSuffix, keyvals is appended to the existing context.
//
// The returned Logger replaces all value elements (odd indexes) containing a
// Valuer with their generated value for each call to its Log method.
func With(logger Logger, keyvals ...interface{}) Logger {
	return log.With(logger, keyvals...)
}

// WithPrefix returns a new contextual logger with keyvals prepended to those
// passed to calls to Log. If logger is also a contextual logger created by
// With, WithPrefix, or WithSuffix, keyvals is prepended to the existing context.
//
// The returned Logger replaces all value elements (odd indexes) containing a
// Valuer with their generated value for each call to its Log method.
func WithPrefix(logger Logger, keyvals ...interface{}) Logger {
	return log.WithPrefix(logger, keyvals...)
}

// WithSuffix returns a new contextual logger with keyvals appended to those
// passed to calls to Log. If logger is also a contextual logger created by
// With, WithPrefix, or WithSuffix, keyvals is appended to the existing context.
//
// The returned Logger replaces all value elements (odd indexes) containing a
// Valuer with their generated value for each call to its Log method.
func WithSuffix(logger Logger, keyvals ...interface{}) Logger {
	return log.WithSuffix(logger, keyvals...)
}

// LoggerFunc is an adapter to allow use of ordinary functions as Loggers. If
// f is a function with the appropriate signature, LoggerFunc(f) is a Logger
// object that calls f.
type LoggerFunc = log.LoggerFunc