OpenWalnut  1.4.0
Public Member Functions | Private Attributes
WLogEntry Class Reference

Represents a simple log message with some attributes. More...

#include <WLogEntry.h>

List of all members.

Public Member Functions

 WLogEntry (std::string logTime, std::string message, LogLevel level, std::string source="")
 Creates a new log message.
virtual ~WLogEntry ()
 Destroys a log message entry.
std::string getLogString (std::string format="[%t] *%l* %m \n", bool colors=true) const
LogLevel getLogLevel () const
std::string getMessage () const
 Returns the plain message of the entry.
std::string getSource () const
 Returns the sender of the log.
std::string getTime () const
 Returns the formatted time string.

Private Attributes

std::string m_time
 The time the log message was received.
std::string m_message
 The actual message.
LogLevel m_level
 Log level.
std::string m_source
 Source (e.g.
WTerminalColor m_errorColor
 Color used for error logs.
WTerminalColor m_infoColor
 Color used for info logs.
WTerminalColor m_debugColor
 Color used for debug logs.
WTerminalColor m_warningColor
 Color used for warning logs.
WTerminalColor m_sourceColor
 Color used for source field.
WTerminalColor m_timeColor
 Color used for time.
WTerminalColor m_messageColor
 Color used for the message.

Detailed Description

Represents a simple log message with some attributes.

Definition at line 56 of file WLogEntry.h.


Constructor & Destructor Documentation

WLogEntry::WLogEntry ( std::string  logTime,
std::string  message,
LogLevel  level,
std::string  source = "" 
)

Creates a new log message.

Parameters:
logTimethe time
messagethe message
levelthe log level
sourcethe source, sending the log

Definition at line 58 of file WLogEntry.cpp.

WLogEntry::~WLogEntry ( ) [virtual]

Destroys a log message entry.

Definition at line 73 of file WLogEntry.cpp.


Member Function Documentation

LogLevel WLogEntry::getLogLevel ( ) const
Returns:
log level of this entry.

Definition at line 116 of file WLogEntry.cpp.

References m_level.

Referenced by WLogStream::printEntry().

std::string WLogEntry::getLogString ( std::string  format = "[%t] *%l* %m \n",
bool  colors = true 
) const
Parameters:
formatA string describing the output format in c printf style
colorsTrue if colors should be used. True is the default.
Returns:
String of this log entry.

Definition at line 77 of file WLogEntry.cpp.

References m_debugColor, m_errorColor, m_infoColor, m_level, m_message, m_messageColor, m_source, m_sourceColor, m_time, m_timeColor, m_warningColor, and WTerminalColor::setEnabled().

Referenced by WLogStream::printEntry(), WLogEntryTest::testEmptyStringAsFormatString(), WLogEntryTest::testFormatStringReplacement(), and WLogEntryTest::testUnkownLogLevel().

std::string WLogEntry::getMessage ( ) const

Returns the plain message of the entry.

Returns:
the message

Definition at line 121 of file WLogEntry.cpp.

References m_message.

std::string WLogEntry::getSource ( ) const

Returns the sender of the log.

Returns:
sender

Definition at line 126 of file WLogEntry.cpp.

References m_source.

std::string WLogEntry::getTime ( ) const

Returns the formatted time string.

Returns:
time string

Definition at line 131 of file WLogEntry.cpp.

References m_time.


Member Data Documentation

Color used for debug logs.

Notes:
it is mutable to allow en-/disabling the colors during getLogString.

Definition at line 149 of file WLogEntry.h.

Referenced by getLogString().

Color used for error logs.

Notes:
it is mutable to allow en-/disabling the colors during getLogString.

Definition at line 135 of file WLogEntry.h.

Referenced by getLogString().

Color used for info logs.

Notes:
it is mutable to allow en-/disabling the colors during getLogString.

Definition at line 142 of file WLogEntry.h.

Referenced by getLogString().

LogLevel WLogEntry::m_level [private]

Log level.

Definition at line 123 of file WLogEntry.h.

Referenced by getLogLevel(), and getLogString().

std::string WLogEntry::m_message [private]

The actual message.

Definition at line 118 of file WLogEntry.h.

Referenced by getLogString(), and getMessage().

Color used for the message.

Notes:
it is mutable to allow en-/disabling the colors during getLogString.

Definition at line 177 of file WLogEntry.h.

Referenced by getLogString().

std::string WLogEntry::m_source [private]

Source (e.g.

module name) where this log message comes from.

Definition at line 128 of file WLogEntry.h.

Referenced by getLogString(), and getSource().

Color used for source field.

Notes:
it is mutable to allow en-/disabling the colors during getLogString.

Definition at line 163 of file WLogEntry.h.

Referenced by getLogString().

std::string WLogEntry::m_time [private]

The time the log message was received.

Definition at line 113 of file WLogEntry.h.

Referenced by getLogString(), and getTime().

Color used for time.

Notes:
it is mutable to allow en-/disabling the colors during getLogString.

Definition at line 170 of file WLogEntry.h.

Referenced by getLogString().

Color used for warning logs.

Notes:
it is mutable to allow en-/disabling the colors during getLogString.

Definition at line 156 of file WLogEntry.h.

Referenced by getLogString().


The documentation for this class was generated from the following files: