logging

package
v0.9.15 Latest Latest
Warning

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

Go to latest
Published: Feb 4, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Close

func Close() error

Close closes the logger and any open file handles

func Debug

func Debug(format string, args ...interface{})

Debug logs a debug message

func Error

func Error(format string, args ...interface{})

Error logs an error message

func Info

func Info(format string, args ...interface{})

Info logs an info message

func Init

func Init(level Level, logFile string, noColor bool) error

Init initializes the global logger with options

func InitWithFormat added in v0.9.15

func InitWithFormat(level Level, format Format, logFile string, noColor bool) error

InitWithFormat initializes the global logger with format option

func IsDebugEnabled

func IsDebugEnabled() bool

IsDebugEnabled returns true if debug logging is enabled

func SetLevel

func SetLevel(level Level)

SetLevel sets the log level for the default logger

func Warn

func Warn(format string, args ...interface{})

Warn logs a warning message

func WrapError

func WrapError(err error, operation, vdbType, endpoint string) error

WrapError wraps an error with VDB operation context

func WrapErrorWithContext

func WrapErrorWithContext(err error, operation, vdbType, endpoint string, context map[string]interface{}) error

WrapErrorWithContext wraps an error with additional context

Types

type ContextError

type ContextError struct {
	Operation string
	VDBType   string
	Endpoint  string
	Context   map[string]interface{}
	Err       error
}

ContextError creates an error with rich context for debugging

func (*ContextError) Error

func (e *ContextError) Error() string

Error implements the error interface

func (*ContextError) Unwrap

func (e *ContextError) Unwrap() error

Unwrap implements error unwrapping

type Format added in v0.9.15

type Format string

Format represents the log output format

const (
	FormatText Format = "text"
	FormatJSON Format = "json"
)

type Level

type Level int

Level represents logging levels

const (
	LevelDebug Level = iota
	LevelInfo
	LevelWarn
	LevelError
)

func GetLevel

func GetLevel() Level

GetLevel returns the current log level

func ParseLevel

func ParseLevel(level string) (Level, error)

ParseLevel parses a log level string

func (Level) String

func (l Level) String() string

String returns the string representation of the level

type Logger

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

Logger provides structured logging with file output support

func WithCollection added in v0.9.15

func WithCollection(vdbType, collection string) *Logger

WithCollection creates a logger with collection context

func WithDocument added in v0.9.15

func WithDocument(vdbType, collection, docID string) *Logger

WithDocument creates a logger with document context

func WithFields added in v0.9.15

func WithFields(fields map[string]interface{}) *Logger

WithFields creates a logger with structured fields

func WithVDB added in v0.9.15

func WithVDB(vdbType, operation string) *Logger

WithVDB creates a logger with VDB context

func (*Logger) Debug added in v0.9.15

func (l *Logger) Debug(format string, args ...interface{})

DebugWithFields logs a debug message with this logger's fields

func (*Logger) Error added in v0.9.15

func (l *Logger) Error(format string, args ...interface{})

ErrorWithFields logs an error message with this logger's fields

func (*Logger) Info added in v0.9.15

func (l *Logger) Info(format string, args ...interface{})

InfoWithFields logs an info message with this logger's fields

func (*Logger) Warn added in v0.9.15

func (l *Logger) Warn(format string, args ...interface{})

WarnWithFields logs a warning message with this logger's fields

Jump to

Keyboard shortcuts

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