// Panicln is equivalent to Println() followed by a call to panic().
funcPanicln(v...interface{}){s:=fmt.Sprintln(v...)std.Output(2,s)panic(s)}
执行后输出日志信息,同时也会触发panic
1
log.Panicln("打印日志信息")
致命日志信息
打印日志后,终止程序
1
2
3
4
5
// Fatal is equivalent to Print() followed by a call to os.Exit(1).
funcFatal(v...interface{}){std.Output(2,fmt.Sprint(v...))os.Exit(1)}
执行日志打印后,程序被终止
1
log.Fatal("打印日志信息")
打印日志信息到文件中
Go语言标准库支持输出日志信息到文件中.
输出日志时的几种状态
1
2
3
4
5
6
7
8
9
const(Ldate=1<<iota// the date in the local time zone: 2009/01/23
Ltime// the time in the local time zone: 01:23:23
Lmicroseconds// microsecond resolution: 01:23:23.123123. assumes Ltime.
Llongfile// full file name and line number: /a/b/c/d.go:23
Lshortfile// final file name element and line number: d.go:23. overrides Llongfile
LUTC// if Ldate or Ltime is set, use UTC rather than the local time zone
LstdFlags=Ldate|Ltime// initial values for the standard logger
)