log

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jul 4, 2026 License: MIT Imports: 4 Imported by: 0

README

go-log 🪵

Tiny structured logging for Go services on zerolog, with OpenTelemetry trace_id/span_id correlation baked in.

📦 Install

go get github.com/Bugs5382/go-log

🚀 Usage

logger := log.New("my-service")
logger.Info().Msg("started")

// Inside a request/span, correlate logs with the active trace:
l := log.Ctx(ctx)
l.Info().Msg("handling request")

New writes JSON to stdout with a timestamp and a service field. Ctx derives a logger that adds trace_id and span_id from the active OpenTelemetry span, pairing with go-otel. 🔗

🛠 Develop

task build    # go build ./...
task test     # go test ./...
task lint     # gofmt check + golangci-lint + yamllint
task license  # inject MIT headers (golic)

⚖️ License

MIT © 2026 Shane

Documentation

Overview

Package log provides zerolog-based structured logging for Go services, with OpenTelemetry trace_id/span_id correlation drawn from the active span context.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Ctx

func Ctx(ctx context.Context) zerolog.Logger

Ctx returns a zerolog.Logger derived from the base logger with the active span's trace_id and span_id attached when ctx carries a valid span. This lets every log line be correlated with its trace in the tracing backend. When no valid span is present, it returns the plain base logger.

func New

func New(service string) zerolog.Logger

New returns a zerolog.Logger that writes JSON to stdout with a timestamp and the given service name attached to every line.

Types

This section is empty.

Jump to

Keyboard shortcuts

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