Skip to content
Snippets Groups Projects
Commit f8372e24 authored by Eric Cano's avatar Eric Cano
Browse files

Moved newline responsiblility from in logger.

The log line creation function Logger::writeLogMsg does not add the trailing newine.
Instead, the overloads of reducedSyslog() do, il needed and after possible line truncation.
parent f3461fbb
Branches
Tags
No related merge requests found
......@@ -60,7 +60,7 @@ void FileLogger::reducedSyslog(const std::string & msg) {
if (-1 == m_fd)
throw cta::exception::Exception("In FileLogger::reducedSyslog(): file is not properly initialized");
// Prepare the string to print (for size)
std::string m = msg.substr(0, m_maxMsgLen);
std::string m = msg.substr(0, m_maxMsgLen) + "\n";
// enter critical section
threading::MutexLocker lock(m_mutex);
......
......@@ -70,7 +70,9 @@ protected:
/**
* A reduced version of syslog. This method is able to set the message
* timestamp. This is necessary when logging messages asynchronously of there
* creation, such as when retrieving logs from the DB.
* creation, such as when retrieving logs from the DB. This function truncates
* the message if necessary. It also adds a new line at the end of the message
* if needed.
*
* @param msg The message to be logged.
*/
......
......@@ -153,9 +153,6 @@ void Logger::writeLogMsg(
// Append raw parameters
os << rawParams;
// Terminate the string
os << "\n";
}
//-----------------------------------------------------------------------------
......
......@@ -43,7 +43,7 @@ void StdoutLogger::prepareForFork() {}
// reducedSyslog
//------------------------------------------------------------------------------
void StdoutLogger::reducedSyslog(const std::string & msg) {
printf("%s", msg.c_str());
printf("%s\n", msg.c_str());
}
} // namespace log
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment