Commit a6ac6c9a authored by Sebastian Eichelbaum's avatar Sebastian Eichelbaum
Browse files

[CHANGE] - new default logging format

parent e3b274b3
......@@ -44,7 +44,8 @@ WLogger::WLogger( std::string fileName, LogLevel level ):
m_LogFileLevel( level ),
m_LogFileName( fileName ),
m_QueueMutex(),
m_colored( true )
m_colored( true ),
m_defaultFormat( "*%l [%s] %m \n" )
{
logger = this;
......@@ -107,7 +108,7 @@ void WLogger::addLogMessage( std::string message, std::string source, LogLevel l
m_LogQueue.push( entry );
#else
// in Debug mode, also add the source
std::cout << entry.getLogString( "*%l*%s* %m \n" );
std::cout << entry.getLogString( m_defaultFormat );
#endif
}
......@@ -138,7 +139,7 @@ void WLogger::processQueue()
// for atomic file usage.
boost::filesystem::path p( "walnut.log" );
boost::filesystem::ofstream ofs( p, boost::filesystem::ofstream::app );
ofs << entry.getLogString();
ofs << entry.getLogString( m_defaultFormat );
}
}
}
......@@ -172,3 +173,13 @@ bool WLogger::isColored()
return m_colored;
}
void WLogger::setDefaultFormat( std::string format )
{
m_defaultFormat = format;
}
std::string WLogger::getDefaultFormat()
{
return m_defaultFormat;
}
......@@ -100,6 +100,20 @@ public:
*/
bool isColored();
/**
* Set the default format used for log entries.
*
* \param format the format string. See WLogEntry for details.
*/
void setDefaultFormat( std::string format );
/**
* Gets the default format used for log entries.
*
* \return format string. See WLogEntry for details.
*/
std::string getDefaultFormat();
/**
* Appends a log message to the logging queue.
*/
......@@ -169,6 +183,11 @@ private:
* Flag determining whether log entries can be colored or not.
*/
bool m_colored;
/**
* The default format used for new log entries.
*/
std::string m_defaultFormat;
};
#endif // WLOGGER_H
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment