tracing

package module
v0.5.2 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2024 License: LGPL-2.1 Imports: 7 Imported by: 0

README

tracing

A slog.Handler modeled after Rust's tracing crate.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CloseBuffer

func CloseBuffer(buf *bytes.Buffer)

Clear a line buffer (while still retaining capacity) and potentially return it to the main buffer pool

func Debug added in v0.5.2

func Debug(msg string, args ...any)

func Error added in v0.5.2

func Error(msg string, args ...any)

func GetBuffer

func GetBuffer() *bytes.Buffer

Get a line buffer from the buffer pool for use

func Info added in v0.5.2

func Info(msg string, args ...any)

func NewHandler

func NewHandler(w io.Writer, opts *Options) slog.Handler

NewHandler - Return a slog.Handler to be used for tracing

func NewSpan

func NewSpan(name string, args ...any) context.Context

Enter a new tracing span, returning its context to be used with `slog` methods. If name == "", then runtime.Callers will be used to get the names of up to 2 functions above NewSpan in the call stack (and will create a context 2 levels deep with this information)

func NewSpanCtx added in v0.5.2

func NewSpanCtx(parent context.Context, name string, args ...any) context.Context

Enter a new tracing span, returning a new context with the new span. If the parent ctx contains a span, the new span will be added as a child

func Warn added in v0.5.2

func Warn(msg string, args ...any)

Types

type Options

type Options struct {
	MinLevel   slog.Level // Minimum level to log
	TimeFormat string     // Time format string compatible (optional)
	Color      bool       // Whether to use ANSI color sequences in output
}

Options - Settings for a Handler

type Span

type Span struct {
	Name   string
	Fields map[string]string
	// contains filtered or unexported fields
}

Span - A tracing span. See https://docs.rs/tracing/latest/tracing/#spans for details

Jump to

Keyboard shortcuts

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