diff --git a/log.go b/log.go index 60395ee..88facb5 100644 --- a/log.go +++ b/log.go @@ -227,13 +227,18 @@ func (log *Logger) logwrite(typ LogLevel, calldepth int, format string, v ...int log.golog.SetPrefix("\x1b[33m" + "UNKN " + header + "\x1b[0m" + " ") } - if typ == FATAL || typ == WARNING || typ == ERROR { + if typ == WARNING || typ == ERROR { log.golog.Output(calldepth, "\x1b[31m"+fmt.Sprintf(format, v...)+"\x1b[0m") } else if typ == INFO || typ == DEBUG { log.golog.Output(calldepth, fmt.Sprintf(format, v...)) } else if typ == NOTICE { calldepth = calldepth + 2 log.golog.Output(calldepth, fmt.Sprintf(format, v...)) + } else if typ == FATAL { + stackstr := strings.Replace(string(debug.Stack()), "\n", "\n== ", -1) + stackstr = "\n== Fatal stack:\n" + str.SkipLine(stackstr, calldepth*2+1) + log.golog.Output(calldepth, fmt.Sprintf(format, v...)+stackstr) + os.Exit(1) } else if typ == PANIC { stackstr := strings.Replace(string(debug.Stack()), "\n", "\n== ", -1) stackstr = "\n== Panic stack:\n" + str.SkipLine(stackstr, calldepth*2+1)