2013-12-15 11:43:31 +01:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"log"
|
|
|
|
"os"
|
|
|
|
)
|
|
|
|
|
2014-01-13 10:29:23 -07:00
|
|
|
var logger *log.Logger
|
2013-12-15 11:43:31 +01:00
|
|
|
|
2014-02-13 08:50:19 +01:00
|
|
|
func init() {
|
|
|
|
log.SetOutput(os.Stderr)
|
|
|
|
logger = log.New(os.Stderr, "", log.Flags())
|
|
|
|
}
|
|
|
|
|
2013-12-15 11:43:31 +01:00
|
|
|
func debugln(vals ...interface{}) {
|
2013-12-30 21:21:31 -05:00
|
|
|
s := fmt.Sprintln(vals...)
|
|
|
|
logger.Output(2, "DEBUG: "+s)
|
2013-12-15 11:43:31 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
func debugf(format string, vals ...interface{}) {
|
2013-12-30 21:21:31 -05:00
|
|
|
s := fmt.Sprintf(format, vals...)
|
|
|
|
logger.Output(2, "DEBUG: "+s)
|
2013-12-15 11:43:31 +01: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...)
|
2014-02-12 23:18:41 +01:00
|
|
|
showGuiError(s)
|
2013-12-15 11:43:31 +01:00
|
|
|
logger.Output(2, "WARNING: "+s)
|
|
|
|
}
|
|
|
|
|
|
|
|
func warnf(format string, vals ...interface{}) {
|
|
|
|
s := fmt.Sprintf(format, vals...)
|
2014-02-12 23:18:41 +01:00
|
|
|
showGuiError(s)
|
2013-12-15 11:43:31 +01:00
|
|
|
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())
|
|
|
|
}
|
|
|
|
}
|