Ejemplo n.º 1
0
// InitLogToStdout sets logging output to stdout (console)
func InitLogToStdout(env string) {
	if env == "dev" {
		colog.SetMinLevel(colog.LDebug)
	} else if env == "stage" {
		colog.SetMinLevel(colog.LInfo)
	}
	colog.SetOutput(os.Stdout)
}
Ejemplo n.º 2
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()

}
Ejemplo n.º 3
0
// InitLogToFile sets logging error output to file (warning level or above)
func InitLogToFile(errorlog string) {
	colog.SetMinLevel(colog.LWarning)
	colog.SetOutput(&lumberjack.Logger{
		Filename:   errorlog,
		MaxSize:    500, // megabytes
		MaxBackups: 3,
		MaxAge:     14, //days
	})
}