logging

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2026 License: MIT Imports: 1 Imported by: 1 module, 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 defines the repo-owned, backend-neutral logging contract used throughout github.com/amikos-tech/ami-gin.

Contract

The Logger interface is intentionally context-free: it does not accept or store a context.Context. Callers own trace correlation externally. The library never injects trace IDs, span IDs, or request IDs into log output.

Adapter Split

The core logging package has no backend dependency. Callers who want to route log output to a specific backend import the appropriate sub-package:

  • logging/slogadapter — adapts *slog.Logger
  • logging/stdadapter — adapts *log.Logger

Importing logging alone does not pull either adapter into the build graph.

Safe-Metadata Restrictions

INFO-level log attributes are limited to the frozen allowlist:

  • operation — coarse operation name (e.g. "evaluate", "encode")
  • predicate_op — operator kind (e.g. "EQ", "GT")
  • path_mode — bounded enum: "exact", "bloom-only", "adaptive-hybrid"
  • status — outcome: "ok" or "error"
  • error.type — normalized error category; unknown values collapse to "other"

Predicate values, field path names, document IDs, row-group IDs, term IDs, and any raw user content must never appear in INFO-level log attributes. Those details may appear only in trace events or behind a LevelDebug guard.

Index

Constants

View Source
const (
	PathModeExact          = "exact"
	PathModeBloomOnly      = "bloom-only"
	PathModeAdaptiveHybrid = "adaptive-hybrid"
)

Bounded path_mode values. Query evaluation uses PathMode.String() which maps to one of these labels only. Tests should enforce both the key list and the bounded value set.

Variables

This section is empty.

Functions

func Debug

func Debug(logger Logger, msg string, attrs ...Attr)

Debug emits a debug-level message. It guards on Enabled before calling Log, avoiding backend dispatch work when debug is disabled.

func Error

func Error(logger Logger, msg string, attrs ...Attr)

Error emits an error-level message.

func Info

func Info(logger Logger, msg string, attrs ...Attr)

Info emits an info-level message.

func Warn

func Warn(logger Logger, msg string, attrs ...Attr)

Warn emits a warn-level message.

Types

type Attr

type Attr struct {
	Key   string
	Value string
}

Attr is a typed key-value pair used by the repo-owned logging contract. The typed surface (rather than variadic any) lets the compiler enforce the frozen vocabulary: callers must construct attrs through the named helpers below rather than passing raw strings or dynamic values.

func AttrErrorType

func AttrErrorType(kind string) Attr

AttrErrorType returns an error.type attr using the frozen key. Unknown kinds collapse to "other".

func AttrOperation

func AttrOperation(name string) Attr

AttrOperation returns an operation attr using the frozen key.

func AttrPathMode

func AttrPathMode(mode string) Attr

AttrPathMode returns a path_mode attr using the frozen key. Callers must use one of the PathMode* constants as the value.

func AttrPredicateOp

func AttrPredicateOp(op string) Attr

AttrPredicateOp returns a predicate_op attr using the frozen key.

func AttrStatus

func AttrStatus(status string) Attr

AttrStatus returns a status attr using the frozen key.

type Level

type Level uint8

Level identifies the supported logging severities.

const (
	LevelDebug Level = iota
	LevelInfo
	LevelWarn
	LevelError
)

type Logger

type Logger interface {
	Enabled(Level) bool
	Log(Level, string, ...Attr)
}

Logger is the repo-owned backend-neutral logging contract. Implementations must be safe for concurrent use. The contract is intentionally context-free: callers manage trace correlation externally; the logger never injects trace IDs or span IDs into log output.

func Default

func Default(logger Logger) Logger

Default returns the supplied logger when non-nil, otherwise the shared noop logger. Boundary packages use this to normalize zero values without guarding every call site.

func NewNoop

func NewNoop() Logger

NewNoop returns the package-wide noop logger. The returned value is the same shared instance on every call; the noop logger has no state.

Directories

Path Synopsis
Package slogadapter wires log/slog into the repo-owned logging contract.
Package slogadapter wires log/slog into the repo-owned logging contract.
Package stdadapter wires the stdlib *log.Logger into the repo-owned logging contract.
Package stdadapter wires the stdlib *log.Logger into the repo-owned logging contract.

Jump to

Keyboard shortcuts

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