Commit 06eeabaa authored by Sebastian Eichelbaum's avatar Sebastian Eichelbaum
Browse files

[CHANGE] - now different formats for log files and console logging used

parent a6ac6c9a
......@@ -45,7 +45,8 @@ WLogger::WLogger( std::string fileName, LogLevel level ):
m_LogFileName( fileName ),
m_QueueMutex(),
m_colored( true ),
m_defaultFormat( "*%l [%s] %m \n" )
m_defaultFormat( "*%l [%s] %m \n" ),
m_defaultFileFormat( "[%t] *%l*%s* %m \n" )
{
logger = this;
......@@ -139,7 +140,11 @@ 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( m_defaultFormat );
bool tmp = entry.isColored();
entry.setColored( false );
ofs << entry.getLogString( m_defaultFileFormat );
entry.setColored( tmp );
}
}
}
......@@ -183,3 +188,13 @@ std::string WLogger::getDefaultFormat()
return m_defaultFormat;
}
void WLogger::setDefaultFileFormat( std::string format )
{
m_defaultFileFormat = format;
}
std::string WLogger::getDefaultFileFormat()
{
return m_defaultFileFormat;
}
......@@ -114,6 +114,20 @@ public:
*/
std::string getDefaultFormat();
/**
* Set the default format used for log entries in log files.
*
* \param format the format string. See WLogEntry for details.
*/
void setDefaultFileFormat( std::string format );
/**
* Gets the default format used for log entries in log files.
*
* \return format string. See WLogEntry for details.
*/
std::string getDefaultFileFormat();
/**
* Appends a log message to the logging queue.
*/
......@@ -188,6 +202,11 @@ private:
* The default format used for new log entries.
*/
std::string m_defaultFormat;
/**
* The default format used for new log entries in files.
*/
std::string m_defaultFileFormat;
};
#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