Elm  2
ELM is a library providing generic data structures, OS-independent interface, plugins and XML.
Logging and pretty-printing

Module for parameTrized pretty-printing logs on the console, with colors, automatically prefixed by source path and such. More...

Classes

class  Color
 Define ANSI colors (including foreground, background, bold and underline) for global use in std C/elm strings/outstreams, using implicit type conversions. More...
 
class  Debug
 Provide necessary static methods to configure debugging for the use of the ELM_DBG* macros. More...
 

Macros

#define ELM_DBG(str)   { if(elm::log::Debug::getDebugFlag()) elm::cout << elm::log::Debug::debugPrefix(__FILE__, __LINE__) << str << elm::color::RCol(); }
 Format and output the string str on the log, depending on the global parameTers set in flags and srcpath_length.
If ELM_NO_DBG is not defined, the alias DBG is available. More...
 
#define ELM_DBGLN(str)   { if(elm::log::Debug::getDebugFlag()) elm::cout << elm::log::Debug::debugPrefix(__FILE__, __LINE__) << str << elm::color::RCol() << elm::io::endl; }
 The same as ELM_DBG, except it adds a new line character at the end.
If ELM_NO_DBG is not defined, the alias DBG is available. More...
 
#define ELM_DBGV(level, str)   { if(level & elm::log::Debug::getVerboseLevel()) ELM_DBG(str); }
 Will only output the string str if (level & verbose_level) is non-null, that is, if one of the bits in the bit mask level is set to 1 in the global variable verbose_level. More...
 

Functions

static void setDebugFlag (bool set=true)
 Enable/Disable debugging messages. More...
 
static void setSourceInfoFlag (bool set=true)
 Enable/Disable printing source info in the prefix of logs. More...
 
static void setNumberingFlag (bool set=true)
 Enable/Disable numbering of the logs. More...
 
static void setColorFlag (bool set=true)
 Enable/Disable the use of colors in logs. More...
 
static void setVerboseLevel (int verbose_level)
 Set the verbose level to use. More...
 
static void setSourcePathLength (int srcpath_length)
 Set a new source path length to use in the prefix of logs. More...
 
static void setPrefixColor (const color::Color &prefix_color)
 Set a new color for the prefix of logs. More...
 
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, the line number of the log, both or neither. More...
 

Detailed Description

Module for parameTrized pretty-printing logs on the console, with colors, automatically prefixed by source path and such.

Macro Definition Documentation

◆ ELM_DBG

#define ELM_DBG (   str)    { if(elm::log::Debug::getDebugFlag()) elm::cout << elm::log::Debug::debugPrefix(__FILE__, __LINE__) << str << elm::color::RCol(); }

#include <include/elm/log/Log.h>

Format and output the string str on the log, depending on the global parameTers set in flags and srcpath_length.
If ELM_NO_DBG is not defined, the alias DBG is available.

Parameters
Strthe string to print

◆ ELM_DBGLN

#define ELM_DBGLN (   str)    { if(elm::log::Debug::getDebugFlag()) elm::cout << elm::log::Debug::debugPrefix(__FILE__, __LINE__) << str << elm::color::RCol() << elm::io::endl; }

#include <include/elm/log/Log.h>

The same as ELM_DBG, except it adds a new line character at the end.
If ELM_NO_DBG is not defined, the alias DBG is available.

Parameters
Strthe string to print

◆ ELM_DBGV

#define ELM_DBGV (   level,
  str 
)    { if(level & elm::log::Debug::getVerboseLevel()) ELM_DBG(str); }

#include <include/elm/log/Log.h>

Will only output the string str if (level & verbose_level) is non-null, that is, if one of the bits in the bit mask level is set to 1 in the global variable verbose_level.

Parameters
Strthe string to print
Levelbitmask to select the levels of verbose that should enable this debug. If level=0, it will never be printed.

Function Documentation

◆ debugPrefixWrapped()

elm::String debugPrefixWrapped ( const char *  file,
int  line 
)
static

#include <include/elm/log/Log.h>

Display prefix of log line, which may include the source path and line number of file, the line number of the log, both or neither.

Returns
The string to display

References elm::_, elm::io::align(), Debug::getNumberingFlag(), Debug::getSourceInfoFlag(), Debug::getSourcePathLength(), String::length(), elm::color::RCol(), elm::io::RIGHT, String::substring(), and elm::io::width().

Referenced by Debug::debugPrefix().

◆ setColorFlag()

static void setColorFlag ( bool  set = true)
inlinestatic

#include <include/elm/log/Log.h>

Enable/Disable the use of colors in logs.

Parameters
Booleanto set the flag to

◆ setDebugFlag()

static void setDebugFlag ( bool  set = true)
inlinestatic

#include <include/elm/log/Log.h>

Enable/Disable debugging messages.

Parameters
Booleanto set the flag to

◆ setNumberingFlag()

static void setNumberingFlag ( bool  set = true)
inlinestatic

#include <include/elm/log/Log.h>

Enable/Disable numbering of the logs.

Parameters
Booleanto set the flag to

◆ setPrefixColor()

void setPrefixColor ( const color::Color prefix_color)
static

#include <include/elm/log/Log.h>

Set a new color for the prefix of logs.

Parameters
Thenew color to use for the prefix of logs

◆ setSourceInfoFlag()

static void setSourceInfoFlag ( bool  set = true)
inlinestatic

#include <include/elm/log/Log.h>

Enable/Disable printing source info in the prefix of logs.

Parameters
Booleanto set the flag to

◆ setSourcePathLength()

static void setSourcePathLength ( int  srcpath_length)
inlinestatic

#include <include/elm/log/Log.h>

Set a new source path length to use in the prefix of logs.

Parameters
Thenew source path length to use for the prefix

◆ setVerboseLevel()

static void setVerboseLevel ( int  verbose_level)
inlinestatic

#include <include/elm/log/Log.h>

Set the verbose level to use.

Parameters
Thenew verbose level to be set