log

package
v0.1.32 Latest Latest
Warning

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

Go to latest
Published: Jun 16, 2024 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FromContext

func FromContext(ctx context.Context) slog.Handler

func NewHandler

func NewHandler(cfg *config.Config) slog.Handler

func NullHandlerContext

func NullHandlerContext(ctx context.Context) context.Context

func SetDefault

func SetDefault(h slog.Handler)

func WithContext

func WithContext(ctx context.Context, l slog.Handler) context.Context

Types

type Entry

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

func New

func New(ctx context.Context) *Entry

New prepares a new entry to write logs.

func (*Entry) Accept

func (entry *Entry) Accept(lvl slog.Level) bool

func (*Entry) Caller

func (entry *Entry) Caller(caller caller.Caller) *Entry

func (*Entry) Debug

func (entry *Entry) Debug(message string, fields ...any)

func (*Entry) Debugf

func (entry *Entry) Debugf(format string, args ...any)

func (*Entry) Err

func (entry *Entry) Err(err error) *Entry

func (*Entry) Error

func (entry *Entry) Error(message string, fields ...any)

func (*Entry) Errorf

func (entry *Entry) Errorf(format string, args ...any)

func (*Entry) Info

func (entry *Entry) Info(message string, fields ...any)

func (*Entry) Infof

func (entry *Entry) Infof(format string, args ...any)

func (*Entry) Level

func (entry *Entry) Level(lvl slog.Level) *Entry

func (*Entry) Log

func (entry *Entry) Log(message string, fields ...any)

func (*Entry) Warn

func (entry *Entry) Warn(message string, fields ...any)

func (*Entry) Warnf

func (entry *Entry) Warnf(format string, args ...any)

func (*Entry) With

func (entry *Entry) With(fields ...any) *Entry

With adds fields to top level of the log entry.

type HTTPClient

type HTTPClient interface {
	Do(req *http.Request) (*http.Response, error)
}

type NullHandler

type NullHandler struct{}

func (NullHandler) Enabled

func (NullHandler) Handle

func (NullHandler) WithAttrs

func (nu NullHandler) WithAttrs([]slog.Attr) slog.Handler

func (NullHandler) WithGroup

func (nu NullHandler) WithGroup(string) slog.Handler

type OpenObserveHandler

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

func NewOpenObserveHandler

func NewOpenObserveHandler(opts OpenObserveHandlerOptions) *OpenObserveHandler

func (*OpenObserveHandler) Enabled

func (sl *OpenObserveHandler) Enabled(ctx context.Context, lvl slog.Level) bool

func (*OpenObserveHandler) Handle

func (sl *OpenObserveHandler) Handle(ctx context.Context, record slog.Record) error

func (*OpenObserveHandler) WithAttrs

func (sl *OpenObserveHandler) WithAttrs(attrs []slog.Attr) slog.Handler

func (*OpenObserveHandler) WithGroup

func (sl *OpenObserveHandler) WithGroup(name string) slog.Handler

type OpenObserveHandlerOptions

type OpenObserveHandlerOptions struct {
	HandlerOptions *slog.HandlerOptions

	// Maximum size for the buffer to store log messages before flushing.
	BufferSize int

	// Maximum time to wait before flushing the buffer.
	BufferTimeout time.Duration

	// Maximum number of concurrent requests to send logs.
	Concurrency int

	// Endpoint to send logs to.
	Endpoint string

	// HTTPClient to use for sending logs.
	HTTPClient HTTPClient

	// Attributes to include in every log message.
	WithAttrs []slog.Attr

	Username string
	Password string
}

type PrettyHandler

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

func NewPrettyHandler

func NewPrettyHandler(writer io.Writer, opts *slog.HandlerOptions) *PrettyHandler

NewPrettyHandler creates a human friendly readable logs.

func (*PrettyHandler) Enabled

func (pr *PrettyHandler) Enabled(ctx context.Context, lvl slog.Level) bool

Enabled implements slog.Handler interface.

func (*PrettyHandler) Handle

func (pr *PrettyHandler) Handle(ctx context.Context, record slog.Record) error

Handle implements slog.Handler interface.

func (*PrettyHandler) WithAttrs

func (pr *PrettyHandler) WithAttrs(attrs []slog.Attr) slog.Handler

WithAttrs implements slog.Handler interface.

func (*PrettyHandler) WithGroup

func (pr *PrettyHandler) WithGroup(name string) slog.Handler

WithGroup implements slog.Handler interface.

type WatermillLogger

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

func (*WatermillLogger) Debug

func (wa *WatermillLogger) Debug(msg string, fields watermill.LogFields)

func (*WatermillLogger) Error

func (wa *WatermillLogger) Error(msg string, err error, fields watermill.LogFields)

func (*WatermillLogger) Info

func (wa *WatermillLogger) Info(msg string, fields watermill.LogFields)

func (*WatermillLogger) Trace

func (wa *WatermillLogger) Trace(msg string, fields watermill.LogFields)

func (*WatermillLogger) With

Jump to

Keyboard shortcuts

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