8 #include "wvcolorlogconsole.h"
12 bool WvColorLogConsole::is_tty(
int fd)
20 bool WvColorLogConsole::is_tty(
int fd)
22 struct termios termios;
23 return tcgetattr(fd, &termios) == 0;
29 bool WvColorLogConsole::can_colorize(
int fd,
const char *TERM)
33 && (strcmp(TERM,
"linux") == 0
34 || strcmp(TERM,
"ansi") == 0
35 || strcmp(TERM,
"xterm") == 0
36 || strcmp(TERM,
"rxvt") == 0);
40 WvColorLogConsole::WvColorLogConsole(
int _fd, WvLog::LogLevel _max_level) :
47 WvColorLogConsole::~WvColorLogConsole()
56 const char *seq = WvColorLogConsole::color_start_seq(last_level);
63 seq = WvColorLogConsole::clear_to_eol_seq(last_level);
65 seq = WvColorLogConsole::color_end_seq(last_level);
76 seq = WvColorLogConsole::color_start_seq(last_level);
83 seq = WvColorLogConsole::clear_to_eol_seq(last_level);
85 seq = WvColorLogConsole::color_end_seq(last_level);
96 seq = WvColorLogConsole::color_start_seq(last_level);
98 seq = WvColorLogConsole::clear_to_eol_seq(last_level);
100 seq = WvColorLogConsole::color_end_seq(last_level);
107 const char *WvColorLogConsole::color_start_seq(WvLog::LogLevel log_level)
109 if (
int(log_level) <=
int(WvLog::Error))
110 return "\e[41;37;1m";
111 else if (
int(log_level) <=
int(WvLog::Warning))
112 return "\e[43;37;1m";
114 return "\e[40;37;1m";
118 const char *WvColorLogConsole::clear_to_eol_seq(WvLog::LogLevel log_level)
124 const char *WvColorLogConsole::color_end_seq(WvLog::LogLevel log_level)
WvLogRcv adds some intelligence to WvLogRcvBase, to keep track of line-prefix-printing and other form...
virtual void _begin_line()
Start a new log line (print prefix)
virtual void _mid_line(const char *str, size_t len)
add text to the current log line.
virtual void _end_line()
End this (Guaranteed NonEmpty) log line.
virtual size_t uwrite(const void *buf, size_t count)
unbuffered I/O functions; these ignore the buffer, which is handled by write().
Captures formatted log messages and outputs them to the specified file descriptor.
virtual void _mid_line(const char *str, size_t len)
add text to the current log line.
virtual void _end_line()
End this (Guaranteed NonEmpty) log line.
virtual void _begin_line()
Start a new log line (print prefix)