mirror of
https://github.com/pikami/cosmium.git
synced 2025-12-20 17:30:30 +00:00
Implement custom logger with log levels
This commit is contained in:
40
internal/logger/logger.go
Normal file
40
internal/logger/logger.go
Normal file
@@ -0,0 +1,40 @@
|
||||
package logger
|
||||
|
||||
import (
|
||||
"log"
|
||||
"os"
|
||||
|
||||
"github.com/pikami/cosmium/api/config"
|
||||
)
|
||||
|
||||
var DebugLogger = log.New(os.Stdout, "", log.Ldate|log.Ltime|log.Lshortfile)
|
||||
var InfoLogger = log.New(os.Stdout, "", log.Ldate|log.Ltime)
|
||||
var ErrorLogger = log.New(os.Stderr, "", log.Ldate|log.Ltime|log.Lshortfile)
|
||||
|
||||
func Debug(v ...any) {
|
||||
if config.Config.Debug {
|
||||
DebugLogger.Println(v...)
|
||||
}
|
||||
}
|
||||
|
||||
func Debugf(format string, v ...any) {
|
||||
if config.Config.Debug {
|
||||
DebugLogger.Printf(format, v...)
|
||||
}
|
||||
}
|
||||
|
||||
func Info(v ...any) {
|
||||
InfoLogger.Println(v...)
|
||||
}
|
||||
|
||||
func Infof(format string, v ...any) {
|
||||
InfoLogger.Printf(format, v...)
|
||||
}
|
||||
|
||||
func Error(v ...any) {
|
||||
ErrorLogger.Println(v...)
|
||||
}
|
||||
|
||||
func Errorf(format string, v ...any) {
|
||||
ErrorLogger.Printf(format, v...)
|
||||
}
|
||||
Reference in New Issue
Block a user