Documentation ¶
Index ¶
- type Config
- type ConfigProvider
- type Debugger
- func (d *Debugger) CreateLogFile() error
- func (d *Debugger) Custom(logLevel LogLevel, msg string, args ...interface{})
- func (d *Debugger) CustomDebug(logLevel LogLevel, msg string, args ...interface{})
- func (d *Debugger) Debug(msg string, args ...interface{})
- func (d *Debugger) DebugDetailed(msg string, err error)
- func (d *Debugger) Error(msg string, args ...interface{})
- func (d *Debugger) ErrorDetailed(msg string, err error)
- func (d *Debugger) Fatal(msg string, args ...interface{})
- func (d *Debugger) FatalDetailed(msg string, err error)
- func (d *Debugger) GetSignalChannel() chan os.Signal
- func (d *Debugger) Info(msg string, args ...interface{})
- func (d *Debugger) InfoDetailed(msg string, err error)
- func (d *Debugger) SetConsoleOutput(mode bool) *Debugger
- func (d *Debugger) SetCustomLogLevelNames(customLogLevelNames map[LogLevel]string) *Debugger
- func (d *Debugger) SetDateFormat(format string) *Debugger
- func (d *Debugger) SetDebugMode(mode bool) *Debugger
- func (d *Debugger) SetDefaultLogPath() *Debugger
- func (d *Debugger) SetDetailedErrorOutput(enabled bool) *Debugger
- func (d *Debugger) SetIsLogFile(isLog bool) *Debugger
- func (d *Debugger) SetLogDate(isLogDate bool) *Debugger
- func (d *Debugger) SetLogDateFileNameFormat(_type string) *Debugger
- func (d *Debugger) SetLogDateFormat(format string) *Debugger
- func (d *Debugger) SetLogFileName(filename string) *Debugger
- func (d *Debugger) SetLogFileType(_type string) *Debugger
- func (d *Debugger) SetLogFormatter(formatter LogFormatter) *Debugger
- func (d *Debugger) SetLogPath(filename string) *Debugger
- func (d *Debugger) SetUserDefinedFormatter(formatFunc UserDefinedFormatterFunc) *Debugger
- func (d *Debugger) Trace(msg string, args ...interface{})
- func (d *Debugger) TraceDetailed(msg string, err error)
- func (d *Debugger) Warning(msg string, args ...interface{})
- func (d *Debugger) WarningDetailed(msg string, err error)
- type DetailedError
- type JSONFormatter
- type LogFormatter
- type LogLevel
- type PlainTextFormatter
- type UserDefinedFormatter
- type UserDefinedFormatterFunc
- type XMLFormatter
- type YAMLFormatter
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { DateFormat string `yaml:"dateFormat" json:"dateFormat" xml:"dateFormat"` IsConsoleOutput bool `yaml:"isConsoleOutput" json:"isConsoleOutput" xml:"isConsoleOutput"` DetailedErrorOutput bool `yaml:"detailedErrorOutput" json:"detailedErrorOutput" xml:"detailedErrorOutput"` LogDateFile bool `yaml:"logDateFile" json:"logDateFile" xml:"logDateFile"` LogDateFileFormat string `yaml:"logDateFileFormat" json:"logDateFileFormat" xml:"logDateFileFormat"` LogFilePath string `yaml:"logFilePath" json:"logFilePath" xml:"logFilePath"` LogFileName string `yaml:"logFileName" json:"logFileName" xml:"logFileName"` LogFileType string `yaml:"logFileType" json:"logFileType" xml:"logFileType"` LogFormat string `json:"logFormat" yaml:"logFormat" xml:"logFormat"` UserFormat string `json:"userFormat" yaml:"userFormat" xml:"userFormat"` // contains filtered or unexported fields }
Config is a struct that represents the configuration settings for logging.
type ConfigProvider ¶
type ConfigProvider interface { IsDebugMode() bool // IsDebugMode returns whether debug mode is enabled. DateFormat() string // DateFormat returns the format for log timestamps. IsConsoleOutput() bool // IsConsoleOutput returns whether console output is enabled. DetailedErrorOutput() bool // DetailedErrorOutput returns whether detailed error output is enabled. LogDateFile() bool // LogDateFile returns whether log date file is enabled. LogDateFileFormat() string // LogDateFileFormat returns the format for the log date file timestamps. LogFilePath() string // LogFilePath returns the path for log files. LogFileName() string // LogFileName returns the name for log files. LogFileType() string // LogFileType returns the type (extension) for log files. LogFormat() string // LogFormat returns the desired log format (e.g., PlainText, JSON, XML, UserDefined). UserFormat() string // UserFormat returns the custom log format if LogFormat is UserDefined. }
ConfigProvider is an interface that defines methods to retrieve configuration parameters for logging.
type Debugger ¶
type Debugger struct {
// contains filtered or unexported fields
}
Debugger is a logging utility that provides various configuration options.
func NewDebugLogger ¶
NewDebugLogger creates a new instance of Debugger with the specified module name and optional submodules. Default parameters:
- logLevel: InfoLevel
- logFormatter: Default log formatter set to PlainTextFormatter with the date format "02.01.2006"
- Signal notification: Debugger is notified about OS interrupt signals
- log.logToFile: Log to file is initially disabled
- log.logDateFileFormat: Default log file date format set to "02.01.2006"
func SetByConfig ¶
SetByConfig initializes a Debugger instance using configuration settings from a file. It takes the file path, file name, module name, and submodules (optional) as parameters. The configuration file format is determined by the file extension. Supported formats: YAML (.yaml, .yml), JSON (.json), XML (.xml). Returns a Debugger instance and an error if any.
func SetByConfigProvider ¶
func SetByConfigProvider(provider ConfigProvider, moduleName string, submodules ...string) (*Debugger, error)
SetByConfigProvider initializes a Debugger instance using the provided ConfigProvider.
func (*Debugger) CreateLogFile ¶
CreateLogFile creates the log file based on the configured settings.
func (*Debugger) Custom ¶
Custom outputs a custom log message at the specified log level. It includes the specified message and error and respects the custom log level names.
func (*Debugger) CustomDebug ¶
CustomDebug outputs a custom log message if debug mode. It includes the specified message and error and respects the custom log level names.
func (*Debugger) Debug ¶
Debug outputs a log message at the Debug level with the specified message and error (if any). It prints the log message to the console and, if enabled, to the log file.
func (*Debugger) DebugDetailed ¶
DebugDetailed outputs a detailed log message at the Debug level. It includes the specified message and error with additional stack trace information. DebugDetailed logs are printed to the console and, if enabled, to the log file.
func (*Debugger) Error ¶
Error outputs a log message at the Error level with the specified message and error (if any). It prints the log message to the console and, if enabled, to the log file.
func (*Debugger) ErrorDetailed ¶
ErrorDetailed outputs a detailed log message at the Error level. It includes the specified message and error with additional stack trace information. ErrorDetailed logs are printed to the console and, if enabled, to the log file.
func (*Debugger) Fatal ¶
Fatal outputs a log message at the Fatal level with the specified message and error (if any). It prints the log message to the console and, if enabled, to the log file.
func (*Debugger) FatalDetailed ¶
FatalDetailed outputs a detailed log message at the Fatal level. It includes the specified message and error with additional stack trace information. FatalDetailed logs are printed to the console and, if enabled, to the log file.
func (*Debugger) GetSignalChannel ¶
GetSignalChannel returns the signal channel used for interrupt signals.
func (*Debugger) Info ¶
Info outputs a log message at the Info level with the specified message and error (if any). It prints the log message to the console and, if enabled, to the log file.
func (*Debugger) InfoDetailed ¶
InfoDetailed outputs a detailed log message at the Info level. It includes the specified message and error with additional stack trace information. InfoDetailed logs are printed to the console and, if enabled, to the log file.
func (*Debugger) SetConsoleOutput ¶
SetConsoleOutput enables or disables console output for log messages.
func (*Debugger) SetCustomLogLevelNames ¶
SetCustomLogLevelNames sets custom log level names provided by the user.
func (*Debugger) SetDateFormat ¶
SetDateFormat sets the date format for log messages.
func (*Debugger) SetDebugMode ¶
SetDebugMode enables or disables debug mode for the Debugger instance.
func (*Debugger) SetDefaultLogPath ¶
func (*Debugger) SetDetailedErrorOutput ¶
SetDetailedErrorOutput enables or disables detailed error output.
func (*Debugger) SetIsLogFile ¶
SetLogFile enables or disables logging to a file and sets the file path and name.
func (*Debugger) SetLogDate ¶
SetLogDate enables or disables the inclusion of the log date in file names.
func (*Debugger) SetLogDateFileNameFormat ¶
func (*Debugger) SetLogDateFormat ¶
SetLogDateFormat sets the date format for log file names.
func (*Debugger) SetLogFileName ¶
func (*Debugger) SetLogFileType ¶
SetLogFileType sets the log file type.
func (*Debugger) SetLogFormatter ¶
func (d *Debugger) SetLogFormatter(formatter LogFormatter) *Debugger
SetLogFormatter sets the log formatter for the Debugger instance.
func (*Debugger) SetLogPath ¶
func (*Debugger) SetUserDefinedFormatter ¶
func (d *Debugger) SetUserDefinedFormatter(formatFunc UserDefinedFormatterFunc) *Debugger
SetUserDefinedFormatter sets a user-defined log formatter function and date format.
func (*Debugger) Trace ¶
Trace outputs a log message at the Trace level with the specified message and error (if any). It prints the log message to the console and, if enabled, to the log file. Trace logs are only printed if the debug mode is enabled, and the log level is set to Trace.
func (*Debugger) TraceDetailed ¶
TraceDetailed outputs a detailed log message at the Trace level. It includes the specified message and error with additional stack trace information. TraceDetailed logs are only printed if the debug mode is enabled, and the log level is set to Trace.
func (*Debugger) Warning ¶
Warning outputs a log message at the Warning level with the specified message and error (if any). It prints the log message to the console and, if enabled, to the log file.
func (*Debugger) WarningDetailed ¶
WarningDetailed outputs a detailed log message at the Warning level. It includes the specified message and error with additional stack trace information. WarningDetailed logs are printed to the console and, if enabled, to the log file.
type DetailedError ¶
type DetailedError struct { Err error // Original error. StackInfo string // Stack trace information. }
DetailedError represents an error with additional stack trace information.
func NewDetailedError ¶
func NewDetailedError(err error) DetailedError
NewDetailedError creates a new DetailedError with the given error and captures the stack trace.
func (DetailedError) Error ¶
func (de DetailedError) Error() string
Error returns the string representation of the DetailedError, including the original error and stack trace.
type JSONFormatter ¶
type JSONFormatter struct {
// contains filtered or unexported fields
}
JSONFormatter is a LogFormatter implementation that formats log messages in JSON.
type LogFormatter ¶
type LogFormatter interface { // Format formats the log message using the specified parameters and returns the formatted log string. Format(logMessage string, logLevel string, moduleName string, submodules []string, timestamp string) string }
LogFormatter is an interface that defines the methods required to format log messages.
type LogLevel ¶
type LogLevel int
LogLevel represents the severity levels of log messages.
const ( DebugLevel LogLevel = iota // DebugLevel represents debug log messages. InfoLevel // InfoLevel represents informational log messages. WarningLevel // WarningLevel represents warning log messages. ErrorLevel // ErrorLevel represents error log messages. FatalLevel // FatalLevel represents fatal log messages. TraceLevel // TraceLevel represents trace log messages. )
type PlainTextFormatter ¶
type PlainTextFormatter struct {
// contains filtered or unexported fields
}
PlainTextFormatter is a LogFormatter implementation that formats log messages in plain text.
type UserDefinedFormatter ¶
type UserDefinedFormatter struct {
// contains filtered or unexported fields
}
UserDefinedFormatter is a LogFormatter implementation that allows users to define their log message formatting.
type UserDefinedFormatterFunc ¶
type UserDefinedFormatterFunc func(logMessage string, logLevel string, moduleName string, submodules []string, timestamp string) string
UserDefinedFormatterFunc is a function type for user-defined log message formatting.
type XMLFormatter ¶
type XMLFormatter struct {
// contains filtered or unexported fields
}
XMLFormatter is a LogFormatter implementation that formats log messages in XML.
type YAMLFormatter ¶
type YAMLFormatter struct {
// contains filtered or unexported fields
}
YAMLFormatter is a LogFormatter implementation that formats log messages in YAML.