Documentation ¶
Index ¶
- Constants
- func ApplyParams(logger LogEntry, params []Param)
- func ContextWithOrgID(ctx context.Context, orgID string) context.Context
- func ContextWithSID(ctx context.Context, sid string) context.Context
- func ContextWithTokenID(ctx context.Context, tokenID string) context.Context
- func ContextWithUID(ctx context.Context, uid string) context.Context
- func SetDefaultLoggerProvider(provider LoggerProvider)
- type AtomicLogLevel
- type LevelChecker
- type LeveledLogger
- type LeveledLoggerCreator
- type LogEntry
- type LogLevel
- type Logger
- type LoggerCreator
- type LoggerProvider
- type MapLogEntry
- type MapValueEntries
- func (m *MapValueEntries) AnyMapValue(key string, values map[string]interface{})
- func (m *MapValueEntries) AnyMapValues() map[string]map[string]interface{}
- func (m *MapValueEntries) StringMapValue(key string, values map[string]string)
- func (m *MapValueEntries) StringMapValues() map[string]map[string]string
- type ObjectValue
- type Param
Constants ¶
const ( TypeKey = "type" TimeKey = "time" UIDKey = "uid" SIDKey = "sid" TokenIDKey = "tokenId" OrgIDKey = "orgId" TraceIDKey = "traceId" UnsafeParamsKey = "unsafeParams" )
Variables ¶
This section is empty.
Functions ¶
func ApplyParams ¶
func ContextWithOrgID ¶ added in v1.41.0
func ContextWithTokenID ¶
func SetDefaultLoggerProvider ¶
func SetDefaultLoggerProvider(provider LoggerProvider)
Types ¶
type AtomicLogLevel ¶ added in v1.17.0
type AtomicLogLevel struct {
// contains filtered or unexported fields
}
AtomicLogLevel wraps atomic.Value containing a LogLevel. Always use NewAtomicLogLevel to create it.
func NewAtomicLogLevel ¶ added in v1.17.0
func NewAtomicLogLevel(level LogLevel) *AtomicLogLevel
func (*AtomicLogLevel) Enabled ¶ added in v1.17.0
func (l *AtomicLogLevel) Enabled(other LogLevel) bool
func (*AtomicLogLevel) Lock ¶ added in v1.17.0
func (*AtomicLogLevel) Lock()
Lock is a no-op used by -copylocks checker from `go vet`.
func (*AtomicLogLevel) LogLevel ¶ added in v1.17.0
func (l *AtomicLogLevel) LogLevel() LogLevel
func (*AtomicLogLevel) SetLevel ¶ added in v1.17.0
func (l *AtomicLogLevel) SetLevel(level LogLevel)
type LevelChecker ¶ added in v1.17.0
type LeveledLogger ¶
type LeveledLoggerCreator ¶
type LeveledLoggerCreator func(w io.Writer, level LogLevel) LeveledLogger
type LogEntry ¶
type LogEntry interface { StringValue(k, v string) OptionalStringValue(k, v string) SafeLongValue(k string, v int64) IntValue(k string, v int32) StringListValue(k string, v []string) StringMapValue(k string, v map[string]string) AnyMapValue(k string, v map[string]interface{}) // ObjectValue logs the provided value associated with the specified key. If marshalerType is non-nil, then if a // custom marshaler is registered for that type, it may be used to log the entry. If marshalerType is nil or no // marshaler is registered for the provided type, the entry should be logged using reflection. ObjectValue(k string, v interface{}, marshalerType reflect.Type) }
type LoggerCreator ¶
type LoggerProvider ¶
type LoggerProvider interface { NewLogger(w io.Writer) Logger NewLeveledLogger(w io.Writer, level LogLevel) LeveledLogger }
func DefaultLoggerProvider ¶
func DefaultLoggerProvider() LoggerProvider
func NewJSONMarshalLoggerProvider ¶
func NewJSONMarshalLoggerProvider() LoggerProvider
NewJSONMarshalLoggerProvider returns a new logger provider that uses a MapLogEntry as its log entry and performs logging by performing a json.Marshal of the MapLogEntry. This is a naive implementation that is not very efficient: its primary purpose is for tests and in-memory usage in scenarios where one does not want to use a logger provider that uses an external library.
func NewNoopLoggerProvider ¶
func NewNoopLoggerProvider() LoggerProvider
NewNoopLoggerProvider returns a LoggerProvider whose implementations are no-ops. That is, they return immediately after doing nothing.
type MapLogEntry ¶
type MapLogEntry interface { LogEntry StringValues() map[string]string SafeLongValues() map[string]int64 IntValues() map[string]int32 StringListValues() map[string][]string StringMapValues() map[string]map[string]string AnyMapValues() map[string]map[string]interface{} ObjectValues() map[string]ObjectValue // Apply applies the values of all of the stored entries of this MapLogEntry to the provided LogEntry. Apply(logEntry LogEntry) // AllValues returns a single map that contains all of the keys and values stored in this entry. AllValues() map[string]interface{} }
func NewMapLogEntry ¶
func NewMapLogEntry() MapLogEntry
type MapValueEntries ¶
type MapValueEntries struct {
// contains filtered or unexported fields
}
func (*MapValueEntries) AnyMapValue ¶
func (m *MapValueEntries) AnyMapValue(key string, values map[string]interface{})
func (*MapValueEntries) AnyMapValues ¶
func (m *MapValueEntries) AnyMapValues() map[string]map[string]interface{}
func (*MapValueEntries) StringMapValue ¶
func (m *MapValueEntries) StringMapValue(key string, values map[string]string)
func (*MapValueEntries) StringMapValues ¶
func (m *MapValueEntries) StringMapValues() map[string]map[string]string
type ObjectValue ¶
type Param ¶
type Param interface {
// contains filtered or unexported methods
}
func Int64Param ¶
func OptionalStringParam ¶
func ParamsWithMessage ¶ added in v1.11.0
ParamsWithMessage returns a new slice that appends a StringParam with the key "message" and value of the provided msg parameter if it is non-empty. If msg is empty, returns the provided slice without modification.