Go 自定义log包日志前缀
LOG包示例
这个示例程序展示如何使用最基本的 log 包
package main
import (
	"log"
)
func init() {
	log.SetPrefix("TRACE: ")
	log.SetFlags(log.Ldate | log.Lmicroseconds | log.Llongfile)
}
func main() {
	// Println 写到标准日志记录器
	log.Println("message")
	// Fatalln 在调用 Println()之后会接着调用 os.Exit(1)
	log.Fatalln("fatal message")
	// Panicln 在调用 Println()之后会接着调用 panic()
	log.Panicln("panic message")
}
TRACE: 2009/10/11 00:07:06.295890 /tmpfs/go/main.go:15: message 
TRACE: 2009/10/11 00:07:06.335909 /tmpfs/go/main.go:18: fatal message 
exit status 1
前缀配置参数
log包的其它配置参数
const (
	// 日期: 2009/10/11
	Ldate = 1 << iota
	// 时间: 00:10:23
	Ltime
	// 时间(毫秒): 00:10:23.123123。
	Lmicroseconds
	// 完整路径的文件名和行号: /a/b/c/d.go:23
	Llongfile
	// 当前文件名和行号: d.go:23
	Lshortfile
	// 标准日志记录器的初始值
	LstdFlags = Ldate | Ltime
	)