package logger import ( "fmt" "os" "git.schreifuchs.ch/schreifuchs/logger/lvl" ) // Log logs a message according to the level func (l *Logger) Log(level lvl.Level, message string) { l.LogChan <- &Log{ Level: level, Message: message, } } // Logf is the same as Log but with fmt.Sprintf func (l *Logger) Logf(level lvl.Level, format string, a ...any) { str := fmt.Sprintf(format, a...) l.Log(level, str) } // Debug logs at the Debug level func (l *Logger) Debug(a ...any) { l.Log(lvl.Debug, fmt.Sprint(a...)) } // Debugf logs formated at the Debug level func (l *Logger) Debugf(format string, a ...any) { l.Logf(lvl.Debug, format, a...) } // Info logs at the Info level func (l *Logger) Info(a ...any) { l.Log(lvl.Info, fmt.Sprint(a...)) } // Infof logs formated at the Info level func (l *Logger) Infof(format string, a ...any) { l.Logf(lvl.Info, format, a...) } // Warn logs at the Warn level func (l *Logger) Warn(str ...any) { l.Log(lvl.Warn, fmt.Sprint(str...)) } // Warnf logs formated at the Warn level func (l *Logger) Warnf(format string, a ...any) { l.Logf(lvl.Warn, format, a...) } // Error logs at the Error level func (l *Logger) Error(a ...any) { l.Log(lvl.Error, fmt.Sprint(a...)) } // Errorf logs formated at the Error level func (l *Logger) Errorf(format string, a ...any) { l.Logf(lvl.Error, format, a...) } // Fatal logs directly do stdout and exis the application with given code. func (l *Logger) Fatal(code int, a ...any) { fmt.Println("Fatal:", fmt.Sprint(a...)) os.Exit(code) } // Fatalf logs formated directly do stdout and exis the application with given code. func (l *Logger) Fatalf(code int, format string, a ...any) { fmt.Println("Fatal:", fmt.Sprintf(format, a...)) os.Exit(code) }