syncthing/logger.go

68 lines
1.2 KiB
Go
Raw Permalink Normal View History

2013-12-15 10:43:31 +00:00
package main
import (
"fmt"
"log"
"os"
)
2013-12-31 02:21:31 +00:00
var logger = log.New(os.Stderr, "", log.Ltime)
2013-12-15 10:43:31 +00:00
func debugln(vals ...interface{}) {
2013-12-31 02:21:31 +00:00
s := fmt.Sprintln(vals...)
logger.Output(2, "DEBUG: "+s)
2013-12-15 10:43:31 +00:00
}
func debugf(format string, vals ...interface{}) {
2013-12-31 02:21:31 +00:00
s := fmt.Sprintf(format, vals...)
logger.Output(2, "DEBUG: "+s)
2013-12-15 10:43:31 +00:00
}
func infoln(vals ...interface{}) {
s := fmt.Sprintln(vals...)
logger.Output(2, "INFO: "+s)
}
func infof(format string, vals ...interface{}) {
s := fmt.Sprintf(format, vals...)
logger.Output(2, "INFO: "+s)
}
func okln(vals ...interface{}) {
s := fmt.Sprintln(vals...)
logger.Output(2, "OK: "+s)
}
func okf(format string, vals ...interface{}) {
s := fmt.Sprintf(format, vals...)
logger.Output(2, "OK: "+s)
}
func warnln(vals ...interface{}) {
s := fmt.Sprintln(vals...)
logger.Output(2, "WARNING: "+s)
}
func warnf(format string, vals ...interface{}) {
s := fmt.Sprintf(format, vals...)
logger.Output(2, "WARNING: "+s)
}
func fatalln(vals ...interface{}) {
s := fmt.Sprintln(vals...)
logger.Output(2, "FATAL: "+s)
os.Exit(3)
}
func fatalf(format string, vals ...interface{}) {
s := fmt.Sprintf(format, vals...)
logger.Output(2, "FATAL: "+s)
os.Exit(3)
}
func fatalErr(err error) {
if err != nil {
fatalf(err.Error())
}
}