logger

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jan 7, 2025 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Level        string
	ReportCaller bool
	JSONFormat   bool
	FileOutput   string
	TimeFormat   string
	TreeFormat   bool
	UseColors    bool
}

Config holds logger configuration

func DefaultConfig

func DefaultConfig() *Config

DefaultConfig returns default logger configuration

type Logger

type Logger struct {
	*logrus.Logger
	// contains filtered or unexported fields
}

Logger extends logrus.Logger with additional functionality

func New

func New(config *Config) (*Logger, error)

New creates a new logger instance with given configuration

func (*Logger) Debug

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

Convenience methods for different log levels

func (*Logger) Debugf

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

func (*Logger) Error

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

func (*Logger) Errorf

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

func (*Logger) Fatal

func (l *Logger) Fatal(args ...interface{})

func (*Logger) Fatalf

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

func (*Logger) GetAllSubLoggers

func (l *Logger) GetAllSubLoggers() map[string]*Logger

GetAllSubLoggers returns all immediate sub-loggers

func (*Logger) GetSubLogger

func (l *Logger) GetSubLogger(name string) *Logger

GetSubLogger retrieves an existing sub-logger by name

func (*Logger) Info

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

func (*Logger) Infof

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

func (*Logger) NewSubLogger

func (l *Logger) NewSubLogger(name string, opts *SubLoggerOpts) *Logger

NewSubLogger creates a new sub-logger with the given name

func (*Logger) Warn

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

func (*Logger) Warnf

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

func (*Logger) WithComponent

func (l *Logger) WithComponent(component string) *Logger

WithComponent adds a component field to the logger

func (*Logger) WithError

func (l *Logger) WithError(err error) *Logger

WithError adds an error to the logger context

func (*Logger) WithField

func (l *Logger) WithField(key string, value interface{}) *Logger

WithField adds a field to the logger context

func (*Logger) WithFields

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

WithFields adds multiple fields to the logger context

func (*Logger) WithScope

func (l *Logger) WithScope(scope string) *Logger

WithScope adds a scope field to the logger

type SubLoggerOpts

type SubLoggerOpts struct {
	// Additional fields to add to the sub-logger
	Fields logrus.Fields
	// Override the log level for this sub-logger (optional)
	Level *logrus.Level
}

SubLoggerOpts contains options for creating a sub-logger

type TreeFormatter

type TreeFormatter struct {
	TimestampFormat string
	ShowCaller      bool
	UseColors       bool
}

func (*TreeFormatter) Format

func (f *TreeFormatter) Format(entry *logrus.Entry) ([]byte, error)

Jump to

Keyboard shortcuts

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