Documentation ¶
Index ¶
- Variables
- type Logger
- func (l *Logger) ConvertLogLevel(level interface{}) string
- func (l *Logger) Debug(msg string, ctx string)
- func (l *Logger) Debugf(format string, input ...interface{})
- func (l *Logger) Error(msg string, ctx string)
- func (l *Logger) Errorf(format string, input ...interface{})
- func (l *Logger) Fatal(msg string, ctx string)
- func (l *Logger) Fatalf(format string, input ...interface{})
- func (l *Logger) Info(msg string, ctx string)
- func (l *Logger) Infof(format string, input ...interface{})
- func (l *Logger) Success(msg string, ctx string)
- func (l *Logger) Successf(format string, input ...interface{})
- func (l *Logger) Warn(msg string, ctx string)
- func (l *Logger) Warnf(format string, input ...interface{})
- type NewLoggerInput
Constants ¶
This section is empty.
Variables ¶
var LogLevels = map[string]string{
"DEBUG": "0",
"INFO": "1",
"WARNING": "2",
"ERROR": "3",
"FATAL": "4",
"0": "DEBUG",
"1": "INFO",
"2": "WARNING",
"3": "ERROR",
"4": "FATAL",
}
A map of log levels with the key as a string of the log level name or the log level number. This means that the following are valid keys:
- "DEBUG" | "0"
- "INFO" | "1"
- "WARNING" | "2"
- "ERROR" | "3"
- "FATAL" | "4"
Functions ¶
This section is empty.
Types ¶
type Logger ¶
type Logger struct { // The name of the application using the logger. AppName string // 0 = DEBUG; 1 = INFO; 2 = WARN; 3 = ERROR; 4 = FATAL LogLevel int }
func NewLogger ¶
func NewLogger(loggerInput *NewLoggerInput) *Logger
Creates a new instance of the Logger.
Parameters:
- appName: The name of the application using the logger. If nil, the default value is "Glogger".
- logLevel: 0 = Debug / 1 = Info / 2 = Warn / 3 = Error / 4 = Fatal. If nil, the default value is 0.
func (*Logger) ConvertLogLevel ¶
Converts a given log level from an int to a string or from a number as a string to a log level name. For example: "0" -> "DEBUG" or "DEBUG" -> "0".
If the log level is a string then it is used as is as the map key. If the log level is an int then it is converted to a string and used as the map key. If none of the above return a value then the LogLevel property of the Logger is used as the map key.
func (*Logger) Debug ¶
Outputs a message to the console using the DEBUG log level, fmt.Println, and coloring the output bright blue.
func (*Logger) Debugf ¶
Outputs a message to the console using the DEBUG log level, fmt.Printf, and coloring the output bright blue.
func (*Logger) Error ¶
Outputs a message to the console using the ERROR log level, fmt.Println, and coloring the output bright red.
func (*Logger) Errorf ¶
Outputs a message to the console using the ERROR log level, fmt.Printf, and coloring the output bright red.
func (*Logger) Fatal ¶
Outputs a message to the console using the FATAL log level, fmt.Println, and coloring the output bright red.
func (*Logger) Fatalf ¶
Outputs a message to the console using the FATAL log level, fmt.Printf, and coloring the output bright red.
func (*Logger) Info ¶
Outputs a message to the console using the INFO log level, fmt.Println, and coloring the output cyan.
func (*Logger) Infof ¶
Outputs a message to the console using the INFO log level, fmt.Printf, and coloring the output cyan.
func (*Logger) Success ¶
Outputs a message to the console using fmt.Println, and coloring the output bright green.
func (*Logger) Successf ¶
Outputs a message to the console using the SUCCESS log level, fmt.Printf, and coloring the output bright green.