package log

import "github.com/ydb-platform/ydb-go-sdk/v3/log"

Index

Constants

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

	QUIET
)

Functions

func Coordination

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

Coordination makes trace.Coordination with logging events from details

func DatabaseSQL

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

DatabaseSQL makes trace.DatabaseSQL with logging events from details

func Default

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

func Discovery

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

func NamesFromContext(ctx context.Context) []string

func Ratelimiter

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

Ratelimiter returns trace.Ratelimiter with logging events from details

func Retry

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

Retry returns trace.Retry with logging events from details

func Scheme

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

Scheme returns trace.Scheme with logging events from details

func Scripting

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

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

Topic returns trace.Topic with logging events from details

func WithColoring

func WithColoring() simpleLoggerOption

func WithLevel

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

func WithLogQuery

func WithLogQuery() logQueryOption

func WithMinLevel

func WithMinLevel(level Level) simpleLoggerOption

func WithNames

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

Types

type Field

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

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

Any constructs untyped Field.

func Bool

func Bool(key string, value bool) Field

Bool constructs Field with BoolType

func Duration

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

Duration constructs Field with DurationType

func Error

func Error(value error) Field

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

func Int

func Int(k string, v int) Field

Int constructs Field with IntType

func Int64

func Int64(k string, v int64) Field

func NamedError

func NamedError(key string, value error) Field

NamedError constructs Field with ErrorType

func String

func String(k, v string) Field

String constructs Field with StringType

func Stringer

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

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

Strings constructs Field with StringsType

func (Field) AnyValue

func (f Field) AnyValue() interface{}

AnyValue is a value getter for fields with AnyType type

func (Field) BoolValue

func (f Field) BoolValue() bool

BoolValue is a value getter for fields with BoolType type

func (Field) DurationValue

func (f Field) DurationValue() time.Duration

DurationValue is a value getter for fields with DurationType type

func (Field) ErrorValue

func (f Field) ErrorValue() error

ErrorValue is a value getter for fields with ErrorType type

func (Field) Int64Value

func (f Field) Int64Value() int64

Int64Value is a value getter for fields with Int64Type type

func (Field) IntValue

func (f Field) IntValue() int

IntValue is a value getter for fields with IntType type

func (Field) Key

func (f Field) Key() string

func (Field) String

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

func (f Field) StringValue() string

StringValue is a value getter for fields with StringType type

func (Field) Stringer

func (f Field) Stringer() fmt.Stringer

Stringer is a value getter for fields with StringerType type

func (Field) StringsValue

func (f Field) StringsValue() []string

StringsValue is a value getter for fields with StringsType type

func (Field) Type

func (f Field) Type() FieldType

type FieldType

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

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

type Level

type Level int

func FromString

func FromString(l string) Level

func LevelFromContext

func LevelFromContext(ctx context.Context) Level

func (Level) BoldColor

func (l Level) BoldColor() string

func (Level) Color

func (l Level) Color() string

func (Level) String

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

type Mapper interface {
	MapLogLevel(level Level) Level
}

type Option

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

Source Files

context.go coordination.go discovery.go driver.go field.go level.go logger.go options.go ratelimiter.go retry.go scheme.go scripting.go sql.go table.go topic.go

Version
v3.57.0
Published
Mar 7, 2024
Platform
darwin/amd64
Imports
15 packages
Last checked
5 minutes ago

Tools for package owners.