log

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jun 23, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package log provides structured logging with automatic token redaction.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RedactString

func RedactString(s string) string

RedactString returns a copy of s with known token query parameters redacted.

Types

type Field

type Field struct {
	Key   string
	Value interface{}
}

Field is a structured log field.

func F

func F(key string, value interface{}) Field

F returns a Field.

type Level

type Level string

Level indicates the severity of a log entry.

const (
	DebugLevel Level = "debug"
	InfoLevel  Level = "info"
	WarnLevel  Level = "warn"
	ErrorLevel Level = "error"
)

type Logger

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

Logger writes structured, redacted log entries.

func New

func New(opts Options) *Logger

New creates a new Logger. If level is empty, defaults to InfoLevel.

func (*Logger) Debug

func (l *Logger) Debug(msg string, fields ...Field)

Debug logs a debug message.

func (*Logger) Error

func (l *Logger) Error(msg string, fields ...Field)

Error logs an error message.

func (*Logger) Info

func (l *Logger) Info(msg string, fields ...Field)

Info logs an info message.

func (*Logger) IsEnabled

func (l *Logger) IsEnabled(level Level) bool

IsEnabled reports whether the given level is enabled.

func (*Logger) Log

func (l *Logger) Log(level Level, msg string, fields ...Field)

Log writes a log entry at the given level.

func (*Logger) Warn

func (l *Logger) Warn(msg string, fields ...Field)

Warn logs a warning message.

type Options

type Options struct {
	Level  Level
	Output io.Writer
	// ExtraSensitiveKeys lists additional keys whose values should always be redacted.
	ExtraSensitiveKeys []string
}

Options configures a Logger.

Jump to

Keyboard shortcuts

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