示例#1
0
func main() {
	// log.SetFlags(log.LstdFlags | log.Lshortfile)
	colog.Register()
	log.Print("register colog")

	colog.SetDefaultLevel(colog.LWarning)
	log.Print("set default level LWarning")

	colog.SetFlags(log.Ldate)
	log.Print("Only date")
	printLogs()

	colog.SetDefaultLevel(colog.LInfo)
	log.Print("set default level LInfo")
	colog.SetFlags(log.LstdFlags | log.Lshortfile)
	log.Print("Date, time, filename")
	printLogs()

	colog.ParseFields(true)
	log.Print("Parse fileds like key=value")
	printLogs()

	colog.SetMinLevel(colog.LWarning)
	log.Print("warn: set minimal level LWarning")
	printLogs()

}
示例#2
0
func main() {
	//Logging setup
	colog.Register()

	//Logging examples by environment
	env = "dev"
	fmt.Println("ENVIRONMENT=", strings.ToUpper(env))
	gologger.InitEnv(env, errorlog)
	printLogs()

	env = "stage"
	fmt.Println("ENVIRONMENT=", strings.ToUpper(env))
	gologger.InitEnv(env, errorlog)
	printLogs()

	env = "prod"
	fmt.Println("ENVIRONMENT=", strings.ToUpper(env))
	gologger.InitEnv(env, errorlog)
	printLogs()
}