|
Elm
2
ELM is a library providing generic data structures, OS-independent interface, plugins and XML.
|
26 #include <elm/io/Output.h>
27 #include <elm/string/CString.h>
28 #include <elm/string/AutoString.h>
44 static inline void setDebugFlag(
bool set =
true) { _flags = _flags-(_flags&DEBUG)+(set*DEBUG); }
46 static inline void setSourceInfoFlag(
bool set =
true) { _flags = _flags-(_flags&SOURCE_INFO)+(set*SOURCE_INFO); }
48 static inline void setNumberingFlag(
bool set =
true) { _flags = _flags-(_flags&NUMBERING)+(set*NUMBERING); }
50 static inline void setColorFlag(
bool set =
true) { _flags = _flags-(_flags&COLOR)+(set*COLOR); }
53 static inline void setVerboseLevel(
int verbose_level) { _verbose_level = verbose_level; }
55 static inline void setSourcePathLength(
int srcpath_length) {
if(srcpath_length > 3) _srcpath_length = srcpath_length; }
57 static inline void setFunctionNameLength(
int function_name_length) {
if(function_name_length > 3) _function_name_length = function_name_length; }
63 static int _verbose_level;
64 static int _srcpath_length;
65 static int _function_name_length;
89 inline operator const char*()
const
90 {
return (*
this)().chars(); }
92 {
return (
out << color()); }
94 {
return out << color().chars(); }
109 const Color
RCol(
"\e[0m");
110 const Color
Bold(
"\e[1m");
111 const Color
Dim(
"\e[2m");
112 const Color
NoBold(
"\e[21m");
113 const Color
NoDim(
"\e[22m");
118 #define ELM_DBG(str) { if(elm::log::Debug::getDebugFlag()) elm::cout << elm::log::Debug::debugPrefix(__FILE__, __LINE__) << str << elm::color::RCol(); } // standard debug
119 #define ELM_DBGLN(str) { if(elm::log::Debug::getDebugFlag()) elm::cout << elm::log::Debug::debugPrefix(__FILE__, __LINE__) << str << elm::color::RCol() << elm::io::endl; } // debug with new line
120 #define ELM_DBGV(level, str) { if(level & elm::log::Debug::getVerboseLevel()) ELM_DBG(str); } // verbose debug
125 #define DBGLN ELM_DBGLN
const Color BIPur("\e[1;95m")
const Color NoBold("\e[21m")
const Color UBla("\e[4;30m")
const Color BWhi("\e[1;37m")
typename type_info< T >::out_t out
Definition: type_info.h:284
const Color IGre("\e[0;92m")
static void setFunctionNameLength(int function_name_length)
Definition: Log.h:57
const Color BRed("\e[1;31m")
static elm::String debugPrefixWrapped(const char *file, int line)
Display prefix of log line, which may include the source path and line number of file,...
Definition: log_Log.cpp:193
const Color BICya("\e[1;96m")
const Color On_IWhi("\e[0;107m")
const Color Bla("\e[0;30m")
const Color BIYel("\e[1;93m")
const Color UWhi("\e[4;37m")
static color::Color getPrefixColor()
Get the current color of the prefix of logs.
Definition: log_Log.cpp:267
const Color On_ICya("\e[0;106m")
const Color UCya("\e[4;36m")
const Color BGre("\e[1;32m")
const Color BIGre("\e[1;92m")
const Color IBla("\e[0;90m")
static int getSourcePathLength()
Retrieve the current length set for the source path in the prefix of logs.
Definition: Log.h:54
const Color IBlu("\e[0;94m")
const Color BPur("\e[1;35m")
const Color BYel("\e[1;33m")
friend std::ostream & operator<<(std::ostream &out, const Color &color)
Definition: Log.h:93
const Color On_IPur("\e[0;105m")
static void setSourceInfoFlag(bool set=true)
Enable/Disable printing source info in the prefix of logs.
Definition: Log.h:46
elm::CString operator()() const
Definition: Log.h:85
static bool getColorFlag()
Check if colors are enabled for the logs.
Definition: Log.h:49
const Color On_IBla("\e[0;100m")
static elm::String debugPrefixFunction(const char *functionName)
Definition: log_Log.cpp:241
const Color On_IYel("\e[0;103m")
const Color BIRed("\e[1;91m")
const Color URed("\e[4;31m")
const Color Pur("\e[0;35m")
friend elm::io::Output & operator<<(elm::io::Output &out, const Color &color)
Definition: Log.h:91
static bool getDebugFlag()
Check if debugging messages are enabled.
Definition: Log.h:43
Define ANSI colors (including foreground, background, bold and underline) for global use in std C/elm...
Definition: Log.h:81
const Color UBlu("\e[4;34m")
const Color BBlu("\e[1;34m")
const Color UGre("\e[4;32m")
const Color UPur("\e[4;35m")
const Color BBla("\e[1;30m")
static void setNumberingFlag(bool set=true)
Enable/Disable numbering of the logs.
Definition: Log.h:48
const Color On_Gre("\e[42m")
static elm::String debugPrefix(const char *file, int line, const char *functionName="")
Definition: log_Log.cpp:226
const Color RCol("\e[0m")
static void setPrefixColor(const color::Color &prefix_color)
Set a new color for the prefix of logs.
Definition: log_Log.cpp:270
const Color On_Red("\e[41m")
const Color On_Blu("\e[44m")
const Color Blu("\e[0;34m")
const Color On_Whi("\e[47m")
const Color Bold("\e[1m")
const Color BIBlu("\e[1;94m")
const Color IPur("\e[0;95m")
static int getFunctionNameLength()
Definition: Log.h:56
const Color BCya("\e[1;36m")
const Color Whi("\e[0;37m")
const Color On_Bla("\e[40m")
static void setColorFlag(bool set=true)
Enable/Disable the use of colors in logs.
Definition: Log.h:50
Provide necessary static methods to configure debugging for the use of the ELM_DBG* macros.
Definition: Log.h:37
static void setDebugFlag(bool set=true)
Enable/Disable debugging messages.
Definition: Log.h:44
static bool getSourceInfoFlag()
Check if printing source info in the prefix of logs is enabled.
Definition: Log.h:45
const Color UYel("\e[4;33m")
const Color On_IRed("\e[0;101m")
const Color Red("\e[0;31m")
const Color Gre("\e[0;32m")
const Color ICya("\e[0;96m")
const Color NoDim("\e[22m")
static void setVerboseLevel(int verbose_level)
Set the verbose level to use.
Definition: Log.h:53
const Color BIWhi("\e[1;97m")
const Color IWhi("\e[0;97m")
string str(const char *s)
Definition: String.h:150
static int getVerboseLevel()
Retrieve the current verbose level.
Definition: Log.h:52
const Color On_Pur("\e[45m")
static bool getNumberingFlag()
Check if the numbering of the logs is enabled.
Definition: Log.h:47
const Color On_Yel("\e[43m")
const Color Cya("\e[0;36m")
const Color On_Cya("\e[46m")
const Color Yel("\e[0;33m")
const Color BIBla("\e[1;90m")
Color(const elm::CString &str)
Definition: Log.h:84
const Color On_IBlu("\e[0;104m")
static void setSourcePathLength(int srcpath_length)
Set a new source path length to use in the prefix of logs.
Definition: Log.h:55
const Color IRed("\e[0;91m")
const Color On_IGre("\e[0;102m")
const Color IYel("\e[0;93m")