capturelog

package
v0.4.1 Latest Latest
Warning

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

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

Documentation

Overview

Package capturelog provides an in-memory implementation of mcpx.Logger that records every event for later assertion. Used by integration and security tests.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Entry

type Entry struct {
	Level   Level
	Message string
	Fields  map[string]any
}

Entry is one captured log event.

type Level

type Level int

Level identifies a log level.

const (
	Debug Level = iota
	Info
	Warn
	Error
)

Logging levels.

func (Level) String

func (l Level) String() string

String returns a human-readable name of the level.

type Logger

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

Logger captures events in memory. Safe for concurrent use.

func New

func New() *Logger

New returns an empty capturing logger.

func (*Logger) Contains

func (l *Logger) Contains(substr string) bool

Contains reports whether substr appears in the message of any captured event or in the rendered string form of any field value.

func (*Logger) ContainsAtLevel

func (l *Logger) ContainsAtLevel(lvl Level, substr string) bool

ContainsAtLevel is Contains but limited to the given level.

func (*Logger) ContainsField

func (l *Logger) ContainsField(key string, value any) bool

ContainsField reports whether any captured event has a field with the given key whose value equals (or stringifies to the same as) value.

func (*Logger) Debug

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

Debug records a Debug-level event.

func (*Logger) Entries

func (l *Logger) Entries() []Entry

Entries returns a copy of all captured events in arrival order.

func (*Logger) EntriesAtLevel

func (l *Logger) EntriesAtLevel(lvl Level) []Entry

EntriesAtLevel returns a copy of captured events at the given level.

func (*Logger) Error

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

Error records an Error-level event.

func (*Logger) Info

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

Info records an Info-level event.

func (*Logger) Reset

func (l *Logger) Reset()

Reset drops all captured events.

func (*Logger) Warn

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

Warn records a Warn-level event.

Jump to

Keyboard shortcuts

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