29 #include <boost/algorithm/string.hpp>
31 #include "WLogEntry.h"
32 #include "WTerminalColor.h"
34 LogLevel logLevelFromString(
const std::string& str )
37 std::string strLower = str;
38 std::transform( str.begin(), str.end(), strLower.begin(), tolower );
39 if( !strLower.compare(
"debug" ) )
43 else if( !strLower.compare(
"info" ) )
47 else if( !strLower.compare(
"warning" ) )
51 else if( !strLower.compare(
"error" ) )
79 std::string s = format;
WTerminalColor m_sourceColor
Color used for source field.
WTerminalColor m_warningColor
Color used for warning logs.
WTerminalColor m_messageColor
Color used for the message.
WTerminalColor m_errorColor
Color used for error logs.
WTerminalColor m_infoColor
Color used for info logs.
std::string getMessage() const
Returns the plain message of the entry.
WTerminalColor m_debugColor
Color used for debug logs.
std::string getSource() const
Returns the sender of the log.
void setEnabled(bool enabled)
With this you can easily trigger whether the color control string is used or if "" is returned...
std::string getLogString(std::string format="[%t] *%l* %m \n", bool colors=true) const
WLogEntry(std::string logTime, std::string message, LogLevel level, std::string source="")
Creates a new log message.
virtual ~WLogEntry()
Destroys a log message entry.
LogLevel getLogLevel() const
std::string getTime() const
Returns the formatted time string.
std::string m_message
The actual message.
std::string m_time
The time the log message was received.
LogLevel m_level
Log level.
WTerminalColor m_timeColor
Color used for time.
Helper class to provide a convenient way to colorize output on the console.
std::string m_source
Source (e.g.