log

package
v1.4.2 Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2026 License: MIT Imports: 8 Imported by: 1

Documentation

Overview

Package log provides colored logging functions with timestamps, log levels, and structured logging support.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Debug added in v1.3.7

func Debug(message string)

Debug logs a debug message with a cyan [DEBUG] prefix and timestamp. Debug messages are only shown when log level is set to LevelDebug. Now includes internal context support infrastructure.

func Debugf added in v1.3.7

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

Debugf logs a formatted debug message.

func DisableColors added in v1.3.7

func DisableColors()

DisableColors disables colored output.

func EnableCallerInfo added in v1.3.7

func EnableCallerInfo()

EnableCallerInfo enables including caller information in logs.

func Error

func Error(message string)

Error logs an error message with a red [ERROR] prefix and timestamp. Now includes internal context support infrastructure.

func Errorf added in v1.3.7

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

Errorf logs a formatted error message.

func Info

func Info(message string)

Info logs an informational message with a blue [INFO] prefix and timestamp. Now includes internal context support infrastructure.

func Infof added in v1.3.7

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

Infof logs a formatted informational message.

func SetConfig added in v1.3.7

func SetConfig(config LoggerConfig)

SetConfig updates the global logger configuration.

func SetMinLevel added in v1.3.7

func SetMinLevel(level LogLevel)

SetMinLevel sets the minimum log level for output.

func SetOutput added in v1.3.7

func SetOutput(writer io.Writer)

SetOutput sets the output writer for logs.

func Success

func Success(message string)

Success logs a success message with a green [SUCCESS] prefix and timestamp. Now includes internal context support infrastructure.

func Successf added in v1.3.7

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

Successf logs a formatted success message.

func Warning

func Warning(message string)

Warning logs a warning message with a yellow [WARNING] prefix and timestamp. Now includes internal context support infrastructure.

func Warningf added in v1.3.7

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

Warningf logs a formatted warning message.

Types

type FieldLogger added in v1.3.7

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

FieldLogger provides structured logging with additional fields.

func WithFields added in v1.3.7

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

WithFields creates a structured log entry with additional fields. This provides a foundation for structured logging while maintaining simplicity.

func (*FieldLogger) Debug added in v1.3.7

func (f *FieldLogger) Debug(message string)

Debug logs a debug message with structured fields.

func (*FieldLogger) Error added in v1.3.7

func (f *FieldLogger) Error(message string)

Error logs an error message with structured fields.

func (*FieldLogger) Info added in v1.3.7

func (f *FieldLogger) Info(message string)

Info logs an info message with structured fields.

func (*FieldLogger) Success added in v1.3.7

func (f *FieldLogger) Success(message string)

Success logs a success message with structured fields.

func (*FieldLogger) Warning added in v1.3.7

func (f *FieldLogger) Warning(message string)

Warning logs a warning message with structured fields.

type LogLevel added in v1.3.7

type LogLevel int

LogLevel represents the severity level of log messages.

const (
	LevelDebug   LogLevel = iota // LevelDebug represents debug-level messages
	LevelInfo                    // LevelInfo represents informational messages
	LevelSuccess                 // LevelSuccess represents success messages
	LevelWarning                 // LevelWarning represents warning messages
	LevelError                   // LevelError represents error messages
)

func (LogLevel) String added in v1.3.7

func (l LogLevel) String() string

String returns the string representation of the log level.

type LoggerConfig added in v1.3.7

type LoggerConfig struct {
	MinLevel     LogLevel  // MinLevel specifies the minimum log level to output
	EnableColors bool      // EnableColors specifies whether to use colored output
	Output       io.Writer // Output specifies the output writer for logs
	EnableCaller bool      // EnableCaller specifies whether to include caller information
	TimeFormat   string    // TimeFormat specifies the timestamp format
}

LoggerConfig holds configuration for the logger.

Jump to

Keyboard shortcuts

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