freebox-exporter/log/log.go

46 lines
741 B
Go
Raw Normal View History

2018-09-05 03:08:48 +02:00
package log
import (
2021-02-28 13:28:12 +01:00
"io/ioutil"
2018-09-05 03:08:48 +02:00
"log"
2021-02-28 13:28:12 +01:00
"os"
2018-09-05 03:08:48 +02:00
)
var (
Debug *log.Logger
Info *log.Logger
Warning *log.Logger
Error *log.Logger
)
2021-02-28 13:28:12 +01:00
func InitDebug() {
Debug = log.New(os.Stdout,
2018-09-05 03:08:48 +02:00
"DEBUG: ",
log.Ldate|log.Ltime|log.Lshortfile)
2021-02-28 13:28:12 +01:00
Info = log.New(os.Stdout,
2018-09-05 03:08:48 +02:00
"INFO: ",
log.Ldate|log.Ltime|log.Lshortfile)
2021-02-28 13:28:12 +01:00
Warning = log.New(os.Stdout,
2018-09-05 03:08:48 +02:00
"WARNING: ",
log.Ldate|log.Ltime|log.Lshortfile)
2021-02-28 13:28:12 +01:00
Error = log.New(os.Stderr,
2018-09-05 03:08:48 +02:00
"ERROR: ",
log.Ldate|log.Ltime|log.Lshortfile)
}
2021-02-28 13:28:12 +01:00
func Init() {
Debug = log.New(ioutil.Discard, "", 0)
Info = log.New(os.Stdout, "", 0)
2021-02-28 22:15:44 +01:00
Warning = log.New(os.Stdout,
"WARNING: ",
log.Ldate|log.Ltime|log.Lshortfile)
Error = log.New(os.Stderr,
"ERROR: ",
log.Ldate|log.Ltime|log.Lshortfile)
2021-02-28 13:28:12 +01:00
}