OpenWalnut  1.5.0dev
Public Member Functions | Private Attributes | List of all members
WLogEntry Class Reference

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

#include <WLogEntry.h>

+ Collaboration diagram for WLogEntry:

Public Member Functions

 WLogEntry (std::string logTime, std::string message, LogLevel level, std::string source="")
 Creates a new log message. More...
 
virtual ~WLogEntry ()
 Destroys a log message entry. More...
 
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. More...
 
std::string getSource () const
 Returns the sender of the log. More...
 
std::string getTime () const
 Returns the formatted time string. More...
 

Private Attributes

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

Detailed Description

Represents a simple log message with some attributes.

Definition at line 56 of file WLogEntry.h.

Constructor & Destructor Documentation

◆ WLogEntry()

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::~WLogEntry ( )
virtual

Destroys a log message entry.

Definition at line 73 of file WLogEntry.cpp.

Member Function Documentation

◆ getLogLevel()

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

Definition at line 116 of file WLogEntry.cpp.

References m_level.

Referenced by WQtMessageDock::addLogMessage(), WMainWindow::event(), WLogStream::printEntry(), and WQtGui::slotAddLog().

+ Here is the caller graph for this function:

◆ getLogString()

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().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getMessage()

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.

Referenced by WQtMessageDock::addLogMessage(), and WMainWindow::event().

+ Here is the caller graph for this function:

◆ getSource()

std::string WLogEntry::getSource ( ) const

Returns the sender of the log.

Returns
sender

Definition at line 126 of file WLogEntry.cpp.

References m_source.

Referenced by WQtMessageDock::addLogMessage(), and WMainWindow::event().

+ Here is the caller graph for this function:

◆ getTime()

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

◆ m_debugColor

WTerminalColor WLogEntry::m_debugColor
mutableprivate

Color used for debug logs.

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

Definition at line 149 of file WLogEntry.h.

Referenced by getLogString().

◆ m_errorColor

WTerminalColor WLogEntry::m_errorColor
mutableprivate

Color used for error logs.

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

Definition at line 135 of file WLogEntry.h.

Referenced by getLogString().

◆ m_infoColor

WTerminalColor WLogEntry::m_infoColor
mutableprivate

Color used for info logs.

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

Definition at line 142 of file WLogEntry.h.

Referenced by getLogString().

◆ m_level

LogLevel WLogEntry::m_level
private

Log level.

Definition at line 123 of file WLogEntry.h.

Referenced by getLogLevel(), and getLogString().

◆ m_message

std::string WLogEntry::m_message
private

The actual message.

Definition at line 118 of file WLogEntry.h.

Referenced by getLogString(), and getMessage().

◆ m_messageColor

WTerminalColor WLogEntry::m_messageColor
mutableprivate

Color used for the message.

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

Definition at line 177 of file WLogEntry.h.

Referenced by getLogString().

◆ m_source

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().

◆ m_sourceColor

WTerminalColor WLogEntry::m_sourceColor
mutableprivate

Color used for source field.

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

Definition at line 163 of file WLogEntry.h.

Referenced by getLogString().

◆ m_time

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().

◆ m_timeColor

WTerminalColor WLogEntry::m_timeColor
mutableprivate

Color used for time.

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

Definition at line 170 of file WLogEntry.h.

Referenced by getLogString().

◆ m_warningColor

WTerminalColor WLogEntry::m_warningColor
mutableprivate

Color used for warning logs.

Note
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: