示例#1
0
文件: log.go 项目: kitech/toxtun
func initLog() {
	logFile = os.Stdout
	log.SetOutput(logFile)
	if colorize {
		color.SetDefaultColor(color.ANSI)
	} else {
		color.SetDefaultColor(color.NoColor)
	}
	infoLog = log.New(logFile, "[INFO] ", logFlags)
	errorLog = log.New(logFile, color.Red("[ERROR] "), logFlags)
	debugLog = log.New(logFile, color.Blue("[DEBUG] "), logFlags)
	requestLog = log.New(logFile, color.Green("[>>>>>] "), logFlags)
	responseLog = log.New(logFile, color.Yellow("[<<<<<] "), logFlags)
}
示例#2
0
文件: log.go 项目: Gary-hao/cow
func initLog() {
	logFile = os.Stdout
	if config.LogFile != "" {
		if f, err := os.OpenFile(expandTilde(config.LogFile),
			os.O_CREATE|os.O_WRONLY|os.O_APPEND, 0600); err != nil {
			fmt.Printf("Can't open log file, logging to stdout: %v\n", err)
		} else {
			logFile = f
		}
	}
	log.SetOutput(logFile)
	if colorize {
		color.SetDefaultColor(color.ANSI)
	} else {
		color.SetDefaultColor(color.NoColor)
	}
	errorLog = log.New(logFile, color.Red("[ERROR] "), log.LstdFlags)
	debugLog = log.New(logFile, color.Blue("[DEBUG] "), log.LstdFlags)
	requestLog = log.New(logFile, color.Green("[>>>>>] "), log.LstdFlags)
	responseLog = log.New(logFile, color.Yellow("[<<<<<] "), log.LstdFlags)
}