示例#1
0
func winCmdOut(level string, catalog string, callin int, v ...interface{}) {
	level = strings.TrimSpace(level)
	level = strings.ToUpper(level)
	//callin = 3
	msg := fmt.Sprint(v...)
	createTime := time.Now()
	_, file, line, ok := runtime.Caller(callin)
	if !ok {
		file = "???"
		line = 0
	}
	fmt.Fprintf(os.Stderr, "%v %s:%d", createTime, file, line)

	logMsg := fmt.Sprintf("\n[%s] %s: %s\n", level, catalog, msg)

	switch level {
	case "TRACE":
		mcon.PrintMagenta(logMsg)
	case "DEBUG":
		mcon.PrintCyan(logMsg)
	case "INFO":
		mcon.PrintGreen(logMsg)
	case "WARN":
		mcon.PrintYellow(logMsg)
	case "ERROR":
		mcon.PrintRed(logMsg)
	default:
		fmt.Fprint(os.Stderr, logMsg)
	}
}
示例#2
0
文件: mio.go 项目: mabetle/mcore
// ReadNotBlankLine .
func ReadNotBlankLine() (result string) {
	for {
		result = ReadLine()
		if String(result).IsBlank() {
			mcon.PrintRed("input blank line, try again:")
		} else {
			break
		}
	}
	return
}