logging

package
v2.0.1 Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2026 License: GPL-3.0 Imports: 7 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package logging configures the standard library's structured slog logger.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(cfg Config) *slog.Logger

New creates a text or JSON slog logger. Output defaults to stderr.

func ParseLevel

func ParseLevel(value string) slog.Level

ParseLevel converts a common level name to slog.Level and defaults to info.

Types

type Config

type Config struct {
	Level     slog.Level
	Format    Format
	AddSource bool
	Output    io.Writer
	Stream    *Stream
}

Config configures a slog logger suitable for AstraEngine.

type Format

type Format string

Format selects the structured log encoding.

const (
	FormatText Format = "text"
	FormatJSON Format = "json"
)

func ParseFormat

func ParseFormat(value string) Format

ParseFormat converts a format name to Format and defaults to text.

type Stream added in v2.0.1

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

Stream broadcasts structured log records without blocking their producer.

func NewStream added in v2.0.1

func NewStream(queue int) *Stream

NewStream creates a stream with a bounded queue for each subscriber.

func (*Stream) Close added in v2.0.1

func (s *Stream) Close()

Close stops the stream and closes every subscriber channel.

func (*Stream) Done added in v2.0.1

func (s *Stream) Done() <-chan struct{}

Done is closed when the stream is closed.

func (*Stream) Publish added in v2.0.1

func (s *Stream) Publish(record []byte)

Publish offers a record to every subscriber, dropping it for full queues.

func (*Stream) Subscribe added in v2.0.1

func (s *Stream) Subscribe() (<-chan []byte, func())

Subscribe returns a log channel and an idempotent unsubscribe function.

func (*Stream) SubscriberCount added in v2.0.1

func (s *Stream) SubscriberCount() int

SubscriberCount reports the number of active subscribers.

Jump to

Keyboard shortcuts

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