Пример #1
0
func terminalMessage(term terminal.Terminal, tc terminal.Control, color []byte, msg string, critical bool) {
	line := make([]byte, 0, len(msg)+16)

	line = append(line, ' ')
	line = append(line, color...)
	line = append(line, '*')
	line = append(line, tc.Escape(term).Reset...)
	line = append(line, []byte(fmt.Sprintf(" (%s) ", time.Now().Format(time.Kitchen)))...)
	if critical {
		line = append(line, tc.Escape(term).Red...)
	}
	line = appendTerminalEscaped(line, []byte(msg))
	if critical {
		line = append(line, tc.Escape(term).Reset...)
	}
	line = append(line, '\n')
	term.Write(line)
}
Пример #2
0
func critical(term terminal.Terminal, tc terminal.Control, msg string) {
	terminalMessage(term, tc, tc.Escape(term).Red, msg, true)
}
Пример #3
0
func warn(term terminal.Terminal, tc terminal.Control, msg string) {
	terminalMessage(term, tc, tc.Escape(term).Magenta, msg, false)
}
Пример #4
0
func alert(term terminal.Terminal, tc terminal.Control, msg string) {
	terminalMessage(term, tc, tc.Escape(term).Red, msg, false)
}
Пример #5
0
func info(term terminal.Terminal, tc terminal.Control, msg string) {
	terminalMessage(term, tc, tc.Escape(term).Blue, msg, false)
}