log

package
v0.2.15 Latest Latest
Warning

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

Go to latest
Published: Dec 30, 2025 License: MIT Imports: 11 Imported by: 4

Documentation

Overview

Package log implements the functions, types, and interfaces for the module.

Package log contains generated code by adptool.

Package log acts as a bridge to the Kratos logging library. The adptool directives below generate wrapper code, making Kratos's logging functions and types directly available in this package without non-idiomatic prefixes.

Package log implements the functions, types, and interfaces for the module.

Package log implements the functions, types, and interfaces for the module.

Index

Constants

View Source
const (
	LevelDebug = kratoslog.LevelDebug
	LevelError = kratoslog.LevelError
	LevelFatal = kratoslog.LevelFatal
	LevelInfo  = kratoslog.LevelInfo
	LevelKey   = kratoslog.LevelKey
	LevelWarn  = kratoslog.LevelWarn
)

Variables

View Source
var (
	DefaultCaller     = kratoslog.DefaultCaller
	DefaultLogger     = kratoslog.DefaultLogger
	DefaultMessageKey = kratoslog.DefaultMessageKey
	DefaultTimestamp  = kratoslog.DefaultTimestamp
)

Functions

func Caller

func Caller(depth int) kratoslog.Valuer

func Context

func Context(ctx context.Context) *kratoslog.Helper

func Debug

func Debug(a ...any)

func Debugf

func Debugf(format string, a ...any)

func Debugw

func Debugw(keyvals ...any)

func Error

func Error(a ...any)

func Errorf

func Errorf(format string, a ...any)

func Errorw

func Errorw(keyvals ...any)

func Fatal

func Fatal(a ...any)

func Fatalf

func Fatalf(format string, a ...any)

func Fatalw

func Fatalw(keyvals ...any)

func FilterFunc

func FilterFunc(f func(level kratoslog.Level, keyvals ...any) bool) kratoslog.FilterOption

func FilterKey

func FilterKey(key ...string) kratoslog.FilterOption

func FilterLevel

func FilterLevel(level kratoslog.Level) kratoslog.FilterOption

func FilterValue

func FilterValue(value ...string) kratoslog.FilterOption

func GetLogger

func GetLogger() kratoslog.Logger

func Info

func Info(a ...any)

func Infof

func Infof(format string, a ...any)

func Infow

func Infow(keyvals ...any)

func LevelOption added in v0.2.0

func LevelOption(level string) slogx.Option

LevelOption converts a string level to a slogx.Option.

func Log

func Log(level kratoslog.Level, keyvals ...any)

func NewDiscard added in v0.2.0

func NewDiscard() kratoslog.Logger

func NewFilter

func NewFilter(logger kratoslog.Logger, opts ...kratoslog.FilterOption) *kratoslog.Filter

func NewHelper

func NewHelper(logger kratoslog.Logger, opts ...kratoslog.Option) *kratoslog.Helper

func NewStdLogger

func NewStdLogger(w io.Writer) kratoslog.Logger

func NewWriter

func NewWriter(logger kratoslog.Logger, opts ...kratoslog.WriterOptionFn) io.Writer

func ParseLevel

func ParseLevel(s string) kratoslog.Level

func SetLogger

func SetLogger(logger kratoslog.Logger)

func Timestamp

func Timestamp(layout string) kratoslog.Valuer

func Value

func Value(ctx context.Context, v any) any

func Warn

func Warn(a ...any)

func Warnf

func Warnf(format string, a ...any)

func Warnw

func Warnw(keyvals ...any)

func With

func With(l kratoslog.Logger, kv ...any) kratoslog.Logger

func WithContext

func WithContext(ctx context.Context, l kratoslog.Logger) kratoslog.Logger

func WithDecorate added in v0.2.13

func WithDecorate(l kratoslog.Logger, info interfaces.AppInfo) kratoslog.Logger

WithDecorate decorates a kratos logger with common service information. It adds fields like service ID, name, version, timestamp, caller, trace ID, and span ID.

func WithLogger added in v0.2.6

func WithLogger(logger Logger) options.Option

func WithMessageKey

func WithMessageKey(k string) kratoslog.Option

func WithSprint

func WithSprint(sprint func(...any) string) kratoslog.Option

func WithSprintf

func WithSprintf(sprintf func(format string, a ...any) string) kratoslog.Option

func WithWriteMessageKey

func WithWriteMessageKey(key string) kratoslog.WriterOptionFn

func WithWriterLevel

func WithWriterLevel(level kratoslog.Level) kratoslog.WriterOptionFn

Types

type DiscardLogger added in v0.2.0

type DiscardLogger struct{}

func (DiscardLogger) Debug added in v0.2.0

func (d DiscardLogger) Debug(msg string, keyvals ...interface{})

func (DiscardLogger) Error added in v0.2.0

func (d DiscardLogger) Error(msg string, keyvals ...interface{})

func (DiscardLogger) Info added in v0.2.0

func (d DiscardLogger) Info(msg string, keyvals ...interface{})

func (DiscardLogger) Log added in v0.2.0

func (d DiscardLogger) Log(level kratoslog.Level, keyvals ...interface{}) error

func (DiscardLogger) Warn added in v0.2.0

func (d DiscardLogger) Warn(msg string, keyvals ...interface{})

type Filter

type Filter = kratoslog.Filter

type FilterOption

type FilterOption = kratoslog.FilterOption

type Helper

type Helper = kratoslog.Helper

type Level

type Level = kratoslog.Level

type Logger

type Logger = kratoslog.Logger

func FromContext added in v0.2.6

func FromContext(ctx options.Context) Logger

func FromOptions added in v0.2.6

func FromOptions(opts []options.Option) Logger

func NewLogger added in v0.2.6

func NewLogger(cfg *loggerv1.Logger) Logger

NewLogger creates a new kratos logger based on the provided configuration. It uses slog as the underlying logging library and slog-kratos as an adapter.

type Option

type Option = kratoslog.Option

type Valuer

type Valuer = kratoslog.Valuer

type WriterOptionFn

type WriterOptionFn = kratoslog.WriterOptionFn

Jump to

Keyboard shortcuts

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