log

package
v3.78.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 4, 2024 License: Apache-2.0 Imports: 15 Imported by: 9

Documentation

Index

Constants

View Source
const (
	TRACE = Level(iota)
	DEBUG
	INFO
	WARN
	ERROR
	FATAL

	QUIET
)

Variables

This section is empty.

Functions

func Coordination added in v3.10.0

func Coordination(l Logger, d trace.Detailer, opts ...Option) (t trace.Coordination)

Coordination makes trace.Coordination with logging events from details

func DatabaseSQL added in v3.34.0

func DatabaseSQL(l Logger, d trace.Detailer, opts ...Option) (t trace.DatabaseSQL)

DatabaseSQL makes trace.DatabaseSQL with logging events from details

func Default added in v3.46.0

func Default(w io.Writer, opts ...simpleLoggerOption) *defaultLogger

func Discovery added in v3.10.0

func Discovery(l Logger, d trace.Detailer, opts ...Option) (t trace.Discovery)

Discovery makes trace.Discovery with logging events from details

func Driver

func Driver(l Logger, d trace.Detailer, opts ...Option) (t trace.Driver)

Driver makes trace.Driver with logging events from details

func NamesFromContext added in v3.46.0

func NamesFromContext(ctx context.Context) []string

func Query added in v3.57.1

func Query(l Logger, d trace.Detailer, opts ...Option) (t trace.Query)

Query makes trace.Query with logging events from details

func Ratelimiter added in v3.10.0

func Ratelimiter(l Logger, d trace.Detailer, opts ...Option) (t trace.Ratelimiter)

Ratelimiter returns trace.Ratelimiter with logging events from details

func Retry added in v3.10.0

func Retry(l Logger, d trace.Detailer, opts ...Option) (t trace.Retry)

Retry returns trace.Retry with logging events from details

func Scheme added in v3.10.0

func Scheme(l Logger, d trace.Detailer, opts ...Option) (t trace.Scheme)

Scheme returns trace.Scheme with logging events from details

func Scripting added in v3.10.0

func Scripting(l Logger, d trace.Detailer, opts ...Option) (t trace.Scripting)

Scripting returns trace.Scripting with logging events from details

func Table

func Table(l Logger, d trace.Detailer, opts ...Option) (t trace.Table)

Table makes trace.Table with logging events from details

func Topic added in v3.34.0

func Topic(l Logger, d trace.Detailer, opts ...Option) (t trace.Topic)

Topic returns trace.Topic with logging events from details

func WithColoring added in v3.46.0

func WithColoring() simpleLoggerOption

func WithLevel added in v3.46.0

func WithLevel(ctx context.Context, lvl Level) context.Context

func WithLogQuery added in v3.35.0

func WithLogQuery() logQueryOption

func WithMinLevel added in v3.46.0

func WithMinLevel(level Level) simpleLoggerOption

func WithNames added in v3.46.0

func WithNames(ctx context.Context, names ...string) context.Context

Types

type Field added in v3.46.0

type Field struct {
	// contains filtered or unexported fields
}

Field represents typed log field (a key-value pair). Adapters should determine Field's type based on Type and use the corresponding getter method to retrieve the value:

switch f.Type() {
case logs.IntType:
    var i int = f.Int()
    // handle int value
case logs.StringType:
    var s string = f.String()
    // handle string value
//...
}

Getter methods must not be called on fields with wrong Type (e.g. calling String() on fields with Type != StringType). Field must not be initialized directly as a struct literal.

func Any added in v3.46.0

func Any(key string, value interface{}) Field

Any constructs untyped Field.

func Bool added in v3.46.0

func Bool(key string, value bool) Field

Bool constructs Field with BoolType

func Duration added in v3.46.0

func Duration(key string, value time.Duration) Field

Duration constructs Field with DurationType

func Error added in v3.46.0

func Error(value error) Field

Error is the same as NamedError("error", value)

func Int added in v3.46.0

func Int(k string, v int) Field

Int constructs Field with IntType

func Int64 added in v3.46.0

func Int64(k string, v int64) Field

func NamedError added in v3.46.0

func NamedError(key string, value error) Field

NamedError constructs Field with ErrorType

func String added in v3.46.0

func String(k, v string) Field

String constructs Field with StringType

func Stringer added in v3.46.0

func Stringer(key string, value fmt.Stringer) Field

Stringer constructs Field with StringerType. If value is nil, resulting Field will be of AnyType instead of StringerType.

func Strings added in v3.46.0

func Strings(key string, value []string) Field

Strings constructs Field with StringsType

func (Field) AnyValue added in v3.46.0

func (f Field) AnyValue() interface{}

AnyValue is a value getter for fields with AnyType type

func (Field) BoolValue added in v3.46.0

func (f Field) BoolValue() bool

BoolValue is a value getter for fields with BoolType type

func (Field) DurationValue added in v3.46.0

func (f Field) DurationValue() time.Duration

DurationValue is a value getter for fields with DurationType type

func (Field) ErrorValue added in v3.46.0

func (f Field) ErrorValue() error

ErrorValue is a value getter for fields with ErrorType type

func (Field) Int64Value added in v3.46.0

func (f Field) Int64Value() int64

Int64Value is a value getter for fields with Int64Type type

func (Field) IntValue added in v3.46.0

func (f Field) IntValue() int

IntValue is a value getter for fields with IntType type

func (Field) Key added in v3.46.0

func (f Field) Key() string

func (Field) String added in v3.46.0

func (f Field) String() string

Returns default string representation of Field value. It should be used by adapters that don't support f.Type directly.

func (Field) StringValue added in v3.46.0

func (f Field) StringValue() string

StringValue is a value getter for fields with StringType type

func (Field) Stringer added in v3.46.0

func (f Field) Stringer() fmt.Stringer

Stringer is a value getter for fields with StringerType type

func (Field) StringsValue added in v3.46.0

func (f Field) StringsValue() []string

StringsValue is a value getter for fields with StringsType type

func (Field) Type added in v3.46.0

func (f Field) Type() FieldType

type FieldType added in v3.46.0

type FieldType int

FieldType indicates type info about the Field. This enum might be extended in future releases. Adapters that don't support some FieldType value should use Field.Fallback() for marshaling.

const (
	// InvalidType indicates that Field was not initialized correctly. Adapters
	// should either ignore such field or issue an error. No value getters should
	// be called on field with such type.
	InvalidType FieldType = iota

	IntType
	Int64Type
	StringType
	BoolType
	DurationType

	// StringsType corresponds to []string
	StringsType

	ErrorType
	// AnyType indicates that the Field is untyped. Adapters should use
	// reflection-based approached to marshal this field.
	AnyType

	// StringerType corresponds to fmt.Stringer
	StringerType
)

func (FieldType) String added in v3.46.0

func (ft FieldType) String() (typeName string)

type Level added in v3.15.0

type Level int

func FromString added in v3.15.0

func FromString(l string) Level

func LevelFromContext added in v3.46.0

func LevelFromContext(ctx context.Context) Level

func (Level) BoldColor added in v3.46.0

func (l Level) BoldColor() string

func (Level) Color added in v3.46.0

func (l Level) Color() string

func (Level) String added in v3.46.0

func (l Level) String() string

type Logger

type Logger interface {
	// Log logs the message with specified options and fields.
	// Implementations must not in any way use slice of fields after Log returns.
	Log(ctx context.Context, msg string, fields ...Field)
}

type Mapper added in v3.46.0

type Mapper interface {
	MapLogLevel(level Level) Level
}

type Option added in v3.46.0

type Option interface {
	// contains filtered or unexported methods
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL