Documentation ¶
Index ¶
- func Print(v ...any)
- func Printf(format string, a ...any)
- func Println(v ...any)
- func Printlnf(format string, a ...any)
- type Level
- type Logger
- func (l *Logger) ChangeLevel(level Level) *Logger
- func (l *Logger) ChangeMinimumLevel(minimumLevel Level) *Logger
- func (l *Logger) Create(name string) *Logger
- func (l *Logger) Print(v ...any)
- func (l *Logger) Printf(format string, a ...any)
- func (l *Logger) Println(v ...any)
- func (l *Logger) Printlnf(format string, a ...any)
- type LoggerOpts
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Print ¶
func Print(v ...any)
Print function is used to print the provided arguments with default settings.
Use New() function to create your own logger.
func Printf ¶
Printf function is used to format the provided string with the arguments and print the result with default settings.
Use New() function to create your own logger.
Types ¶
type Level ¶
type Level string
Level type is to define the logging levels, which would be used for saturating logs.
Note: In case you create new levels, they must be added to the LevelToNum and LevelToColor maps.
var ( // LevelDebug is the DEBUG level which should be used for debugging. LevelDebug Level = "DEBUG" // LevelMain is the MAIN level which should be used for logging main arguments. LevelMain Level = "MAIN" // LevelInfo is the INFO level which should be used for logging all basic arguments. LevelInfo Level = "INFO" // LevelError is the ERROR level which should be used for logging all errors. LevelError Level = "ERROR" // LevelCritical is the CRITICAL level which should be used for logging all critical things. LevelCritical Level = "CRITICAL" // LevelToNum map converts the provided level to its integral value. // // One should add custom created levels to this map for proper functioning. LevelToNum = map[Level]int{ LevelDebug: -1, LevelInfo: 0, LevelMain: 1, LevelError: 2, LevelCritical: 3, } // LevelToColor map converts the provided level to its defined color. // // One should add custom created levels to this map for proper functioning. LevelToColor = map[Level]color{ LevelDebug: white, LevelInfo: blue, LevelMain: green, LevelError: purple, LevelCritical: red, } )
type Logger ¶
type Logger struct { Name string Level Level NoColor bool // contains filtered or unexported fields }
Logger is the main struct of the library which implements methods for logging.
Name (type string): Name of the new module you want to inherit into. Level (type Level): Current running level of the logger. NoColor (type bool): Enable it if you want to disable colors.
func (*Logger) ChangeLevel ¶
ChangeLevel method should be used to change the level of current logger.
func (*Logger) ChangeMinimumLevel ¶
ChangeMinimumLevel method should be used to change the minimum printable level of current logger.
func (*Logger) Create ¶
Create method is used when you want to initalise logger for a new module, parent logger will be inherited with a few mutations.
func (*Logger) Printf ¶
Printf method is used to format the provided string with the arguments and print the result with custom settings.
type LoggerOpts ¶
LoggerOpts contain all the optional fields of New Logger.