WvStreams
|
00001 /* -*- Mode: C++ -*- 00002 * Worldvisions Weaver Software: 00003 * Copyright (C) 1997-2002 Net Integration Technologies, Inc. 00004 * 00005 * A version of WvLogConsole that colorizes output on terminals 00006 * which support ANSI color sequences 00007 */ 00008 #ifndef __WVCOLORLOGCONSOLE_H 00009 #define __WVCOLORLOGCONSOLE_H 00010 00011 #include "wvlogrcv.h" 00012 00017 class WvColorLogConsole: public WvLogConsole 00018 { 00019 bool colorize; 00020 00021 public: 00022 WvColorLogConsole(int _fd, 00023 WvLog::LogLevel _max_level = WvLog::NUM_LOGLEVELS); 00024 virtual ~WvColorLogConsole(); 00025 00026 static bool is_tty(int fd); 00027 static bool can_colorize(int fd, const char *TERM); 00028 00029 static const char *color_start_seq(WvLog::LogLevel log_level); 00030 static const char *clear_to_eol_seq(WvLog::LogLevel log_level); 00031 static const char *color_end_seq(WvLog::LogLevel log_level); 00032 00033 protected: 00034 virtual void _begin_line(); 00035 virtual void _mid_line(const char *str, size_t len); 00036 virtual void _end_line(); 00037 }; 00038 00039 #endif // __WVCOLORLOGCONSOLE_H