logger

package
v1.462.0 Latest Latest
Warning

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

Go to latest
Published: Feb 22, 2025 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

Module for fx.

Functions

func Error added in v1.461.2

func Error(err error) slog.Attr

Error returns an Attr for a string value if err is set, otherwise returns an empty Attr.

func IsEnabled added in v1.455.0

func IsEnabled(cfg *Config) bool

IsEnabled for logger.

func Meta added in v1.455.0

func Meta(ctx context.Context) []slog.Attr

Meta for logger.

Types

type Config added in v1.455.0

type Config struct {
	Headers header.Map `yaml:"headers,omitempty" json:"headers,omitempty" toml:"headers,omitempty"`
	Kind    string     `yaml:"kind,omitempty" json:"kind,omitempty" toml:"kind,omitempty"`
	URL     string     `yaml:"url,omitempty" json:"url,omitempty" toml:"url,omitempty"`
	Level   string     `yaml:"level,omitempty" json:"level,omitempty" toml:"level,omitempty"`
}

Config for logger.

func (*Config) IsOTLP added in v1.461.1

func (c *Config) IsOTLP() bool

IsOTLP configuration.

func (*Config) IsStdout added in v1.461.1

func (c *Config) IsStdout() bool

IsStdout configuration.

type Logger added in v1.456.0

type Logger struct {
	*slog.Logger
}

Logger allows to pass a function to log.

func NewLogger added in v1.455.0

func NewLogger(params Params) (*Logger, error)

NewLogger using zap.

func (*Logger) Log added in v1.456.0

func (l *Logger) Log(ctx context.Context, msg Message, attrs ...slog.Attr)

Log attrs for logger.

func (*Logger) LogAttrs added in v1.461.0

func (l *Logger) LogAttrs(ctx context.Context, level slog.Level, msg Message, attrs ...slog.Attr)

LogAttrs for logger.

type Message added in v1.461.2

type Message struct {
	Error error
	Text  string
}

Message represents a log message with text and error information.

func NewMessage added in v1.461.2

func NewMessage(text string, err error) Message

NewMessage creates a new log message with text and error information.

func NewText added in v1.461.2

func NewText(text string) Message

NewText creates a new log message with text information.

func (Message) Level added in v1.461.2

func (m Message) Level() slog.Level

Level returns the log level for the message.

type Params added in v1.455.0

type Params struct {
	fx.In

	Lifecycle   fx.Lifecycle
	FileSystem  os.FileSystem
	Config      *Config
	Environment env.Environment
	Version     env.Version
	Name        env.Name
}

Params for logger.

Jump to

Keyboard shortcuts

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