mastodon-group-bot/logger.go

24 lines
582 B
Go
Raw Normal View History

2022-08-28 16:37:43 +00:00
package main
import (
2022-09-23 04:42:52 +00:00
"io"
2022-08-28 16:37:43 +00:00
"log"
"os"
)
var (
InfoLogger *log.Logger
WarnLogger *log.Logger
ErrorLogger *log.Logger
)
2022-09-08 12:26:25 +00:00
func LoggerInit() {
2022-08-28 16:37:43 +00:00
file, err := os.OpenFile(*LogPath, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0600)
if err != nil {
log.Fatal("Failed to read log file")
}
2022-09-23 04:42:52 +00:00
InfoLogger = log.New(io.MultiWriter(os.Stdout, file), "[INFO] ", log.LstdFlags|log.Lshortfile)
WarnLogger = log.New(io.MultiWriter(os.Stdout, file), "[WARNING] ", log.LstdFlags|log.Lshortfile)
ErrorLogger = log.New(io.MultiWriter(os.Stdout, file), "[ERROR] ", log.LstdFlags|log.Lshortfile)
2022-08-28 16:37:43 +00:00
}