log

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 10, 2025 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FormatJSON Format = iota
	FormatCBOR
	FormatText
	FormatDebug

	PairFunctionName = "pair"

	EnterSuffix = "Enter"
	LeaveSuffix = "Leave"
	CallDepth   = 5
)

Variables

This section is empty.

Functions

func CallTrace

func CallTrace()

CallTrace logs a call trace using the global logger.

func ID

func ID() uint64

ID generates a unique ID for function call tracking. Uses the default logger's counter for backward compatibility.

func IsCalledFrom

func IsCalledFrom(s string) bool

IsCalledFrom returns true if the function call stack contains the search string.

func Log

func Log(fn *FuncCall)

Log logs a function call using the global logger.

func LogEnter

func LogEnter(id uint64, name string, args []any)

LogEnter logs a function entry using the global logger.

func LogLeave

func LogLeave(id uint64, name string, args []any, results []any)

LogLeave logs a function exit using the global logger.

Types

type Format

type Format int

type FuncCall

type FuncCall struct {
	Name    string    `json:"name" cbor:"name"`
	Args    []string  `json:"args" cbor:"args"`
	Results []string  `json:"results" cbor:"results"`
	Time    time.Time `json:"time" cbor:"time"`
}

func (*FuncCall) String

func (f *FuncCall) String() string

type Logger

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

func NewLogger

func NewLogger(format Format) *Logger

NewLogger creates a new Logger instance with the specified format. This allows for instance-based logging instead of relying on global state.

func (*Logger) CallTrace

func (l *Logger) CallTrace()

func (*Logger) ID

func (l *Logger) ID() uint64

ID method for instance-based usage.

func (*Logger) Log

func (l *Logger) Log(fn *FuncCall)

Log is the central logging function. It sends the event to the buffered channel. Uses non-blocking sends to prevent WireGuard worker deadlocks.

func (*Logger) LogEnter

func (l *Logger) LogEnter(id uint64, name string, args []any)

func (*Logger) LogLeave

func (l *Logger) LogLeave(id uint64, name string, args []any, results []any)

type TimedEvent

type TimedEvent struct {
	Time  int64     `json:"time" cbor:"time"`
	Event *WeakTerm `json:"event" cbor:"event"`
}

type WeakTerm

type WeakTerm struct {
	Name  string     `json:"name,omitempty" cbor:"name,omitempty"`
	Type  string     `json:"type,omitempty" cbor:"type,omitempty"`
	Value string     `json:"value,omitempty" cbor:"value,omitempty"`
	Args  []WeakTerm `json:"args,omitempty" cbor:"args,omitempty"`
}

Jump to

Keyboard shortcuts

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