Documentation
¶
Index ¶
- Variables
- type Color
- type Formatter
- type Level
- type Logger
- type LoggerOptions
- func (l *LoggerOptions) Debug(msg string, args ...interface{})
- func (l *LoggerOptions) Error(msg string, args ...interface{})
- func (l *LoggerOptions) Fatal(msg string, args ...interface{})
- func (l *LoggerOptions) Info(msg string, args ...interface{})
- func (l *LoggerOptions) Test(msg string, args ...interface{})
- func (l *LoggerOptions) Warn(msg string, args ...interface{})
Constants ¶
This section is empty.
Variables ¶
var Colors = map[Color]string{ Red: "\033[0;31m", Blue: "\033[0;34m", Green: "\033[0;32m", Yellow: "\033[0;33m", Purple: "\033[0;35m", Cyan: "\033[0;36m", Gray: "\033[0;37m", Orange: "\033[0;91m", Reset: "\033[0m", }
Colors is a map that associates each Color with its corresponding ANSI escape code.
Functions ¶
This section is empty.
Types ¶
type Formatter ¶
type Formatter struct {
LogHolder string
Message string
Args []interface{}
Color string // Holds the color for the holder
}
Formatter struct represents the log message formatter including the color.
func (*Formatter) Format ¶
Format formats the log message using the specified color and log holder. If no color is specified, it defaults to no color. It returns the formatted log message as a string.
func (*Formatter) Log ¶
func (f *Formatter) Log()
Log prints the formatted log message to the console.
func (*Formatter) SetColor ¶
SetColor sets the color of the formatter. It takes a Color parameter and assigns the corresponding color value from the Colors map to the Formatter's Color field.
func (*Formatter) SetMessage ¶
SetMessage sets the log message and arguments.
type Logger ¶
type Logger interface {
Info(msg string, args ...interface{})
Debug(msg string, args ...interface{})
Test(msg string, args ...interface{})
Warn(msg string, args ...interface{})
Error(msg string, args ...interface{})
Fatal(msg string, args ...interface{})
}
Logger interface defines the methods that any logger implementation should have.
func Msg ¶
func Msg() Logger
GetLogger returns the singleton instance of LoggerOptions. Msg returns an instance of the Logger. The Logger is a singleton object that provides logging functionality. It initializes the LoggerOptions with default values if it hasn't been initialized before. The LoggerOptions controls various logging options such as formatter, color enablement, and log level visibility.
type LoggerOptions ¶
type LoggerOptions struct {
Formatter Formatter
}
LoggerOptions struct represents the default logger implementation.
func (*LoggerOptions) Debug ¶
func (l *LoggerOptions) Debug(msg string, args ...interface{})
Debug logs a debug message with the specified message and arguments.
func (*LoggerOptions) Error ¶
func (l *LoggerOptions) Error(msg string, args ...interface{})
Error logs an error message with the specified message and arguments.
func (*LoggerOptions) Fatal ¶
func (l *LoggerOptions) Fatal(msg string, args ...interface{})
Fatal logs a fatal message with the specified message and arguments.
func (*LoggerOptions) Info ¶
func (l *LoggerOptions) Info(msg string, args ...interface{})
Info logs an info message with the specified message and arguments.
func (*LoggerOptions) Test ¶
func (l *LoggerOptions) Test(msg string, args ...interface{})
func (*LoggerOptions) Warn ¶
func (l *LoggerOptions) Warn(msg string, args ...interface{})
Warn logs a warning message with the specified message and arguments.
