logging

package
v0.4.8 Latest Latest
Warning

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

Go to latest
Published: May 5, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package logging provides structured logging for JVS. It supports multiple log levels and field-based logging.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Debug

func Debug(msg string, fields ...map[string]any)

Debug logs to the global logger.

func Error

func Error(msg string, fields ...map[string]any)

Error logs to the global logger.

func ErrorErr

func ErrorErr(msg string, err error, fields ...map[string]any)

ErrorErr logs to the global logger with an error.

func Info

func Info(msg string, fields ...map[string]any)

Info logs to the global logger.

func SetGlobal

func SetGlobal(l *Logger)

SetGlobal sets the global logger.

func Warn

func Warn(msg string, fields ...map[string]any)

Warn logs to the global logger.

Types

type Level

type Level string

Level represents a log level.

const (
	LevelDebug Level = "debug"
	LevelInfo  Level = "info"
	LevelWarn  Level = "warn"
	LevelError Level = "error"
)

type LogEntry

type LogEntry struct {
	Timestamp string         `json:"timestamp"`
	Level     Level          `json:"level"`
	Message   string         `json:"message"`
	Fields    map[string]any `json:"fields,omitempty"`
}

LogEntry represents a structured log entry.

type Logger

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

Logger provides structured logging.

func NewLogger

func NewLogger(level Level) *Logger

NewLogger creates a new logger with the specified level.

func WithFields

func WithFields(fields map[string]any) *Logger

WithFields returns a new logger from global with additional fields.

func (*Logger) Debug

func (l *Logger) Debug(msg string, fields ...map[string]any)

Debug logs a debug message.

func (*Logger) Error

func (l *Logger) Error(msg string, fields ...map[string]any)

Error logs an error message.

func (*Logger) ErrorErr

func (l *Logger) ErrorErr(msg string, err error, fields ...map[string]any)

ErrorErr logs an error message with an error value.

func (*Logger) Info

func (l *Logger) Info(msg string, fields ...map[string]any)

Info logs an info message.

func (*Logger) SetLevel

func (l *Logger) SetLevel(level Level)

SetLevel sets the log level.

func (*Logger) SetOutput

func (l *Logger) SetOutput(w io.Writer)

SetOutput sets the output writer.

func (*Logger) Warn

func (l *Logger) Warn(msg string, fields ...map[string]any)

Warn logs a warning message.

func (*Logger) WithFields

func (l *Logger) WithFields(fields map[string]any) *Logger

WithFields returns a new logger with additional fields.

Jump to

Keyboard shortcuts

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