Esempio n. 1
0
func InitLogger() {
	processName := path.Base(os.Args[0])
	baseName := strings.Replace(processName, ".exe", "", -1)
	logFilename := fmt.Sprintf("%s.log", baseName)

	// Log levels (DEBUG, INFO, NOTICE, WARNING, ERROR, CRITICAL)

	log = alog.NewLogger(processName)
	log.SetLevel(alog.DEBUG) // forward all messages to handler

	consoleLog := alog.NewWriterHandler(os.Stderr)
	consoleLog.SetFormatter(logFormatter{})
	consoleLog.SetLevel(alog.DEBUG)
	consoleLog.Colorize = true

	fileLog := alog.NewWriterHandler(logFile(logFilename))
	fileLog.SetLevel(alog.NOTICE)
	//log.SetHandler(fileLog)

	multi := alog.NewMultiHandler(consoleLog, fileLog)
	multi.SetFormatter(logFormatter{})

	log.SetHandler(multi)

}
Esempio n. 2
0
func init() {
	h := log.NewWriterHandler(os.Stderr)
	h.SetFormatter(logFormatter{})
	h.Colorize = true
	DefaultLogHandler = h
}