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;
virtual ~WLogEntry()
Destroys a log message entry.
std::string m_source
Source (e.g.
WLogEntry(std::string logTime, std::string message, LogLevel level, std::string source="")
Creates a new log message.
std::string m_message
The actual message.
std::string getLogString(std::string format="[%t] *%l* %m \n", bool colors=true) const
LogLevel m_level
Log level.
LogLevel getLogLevel() const
WTerminalColor m_timeColor
Color used for time.
std::string getMessage() const
Returns the plain message of the entry.
WTerminalColor m_errorColor
Color used for error logs.
WTerminalColor m_sourceColor
Color used for source field.
WTerminalColor m_messageColor
Color used for the message.
std::string m_time
The time the log message was received.
std::string getSource() const
Returns the sender of the log.
std::string getTime() const
Returns the formatted time string.
WTerminalColor m_warningColor
Color used for warning logs.
WTerminalColor m_infoColor
Color used for info logs.
WTerminalColor m_debugColor
Color used for debug logs.
Helper class to provide a convenient way to colorize output on the console.
void setEnabled(bool enabled)
With this you can easily trigger whether the color control string is used or if "" is returned.