Skip to content
Snippets Groups Projects
Commit 6d1afefe authored by Tigran Mkrtchyan's avatar Tigran Mkrtchyan :coffee: Committed by Michael Davis
Browse files

common: let StdoutLogger skip header, if desired


When StdoutLogger is used in combination with systemd, then header
becomes redundant.

Signed-off-by: default avatarTigran Mkrtchyan <tigran.mkrtchyan@desy.de>
parent 9627d71f
No related branches found
No related tags found
No related merge requests found
...@@ -23,8 +23,8 @@ namespace log { ...@@ -23,8 +23,8 @@ namespace log {
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// constructor // constructor
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
StdoutLogger::StdoutLogger(const std::string &hostName, const std::string &programName): StdoutLogger::StdoutLogger(const std::string &hostName, const std::string &programName, bool simple):
Logger(hostName, programName, DEBUG) { Logger(hostName, programName, DEBUG), m_simple(simple) {
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
...@@ -42,8 +42,13 @@ void StdoutLogger::prepareForFork() {} ...@@ -42,8 +42,13 @@ void StdoutLogger::prepareForFork() {}
// writeMsgToUnderlyingLoggingSystem // writeMsgToUnderlyingLoggingSystem
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void StdoutLogger::writeMsgToUnderlyingLoggingSystem(const std::string &header, const std::string &body) { void StdoutLogger::writeMsgToUnderlyingLoggingSystem(const std::string &header, const std::string &body) {
const std::string headerPlusBody = header + body;
printf("%s\n", headerPlusBody.c_str()); if (m_simple) {
printf("%s\n", body.c_str());
} else {
const std::string headerPlusBody = header + body;
printf("%s\n", headerPlusBody.c_str());
}
} }
} // namespace log } // namespace log
......
...@@ -34,8 +34,9 @@ public: ...@@ -34,8 +34,9 @@ public:
* @param hostName The name of the host to be prepended to every log message. * @param hostName The name of the host to be prepended to every log message.
* @param programName The name of the program to be prepended to every log * @param programName The name of the program to be prepended to every log
* message. * message.
* @param simple If true, then logging header is not included.
*/ */
StdoutLogger(const std::string &hostName, const std::string &programName); StdoutLogger(const std::string &hostName, const std::string &programName, bool simple = false);
/** /**
* Destructor. * Destructor.
...@@ -69,6 +70,9 @@ protected: ...@@ -69,6 +70,9 @@ protected:
*/ */
void writeMsgToUnderlyingLoggingSystem(const std::string &header, const std::string &body) override; void writeMsgToUnderlyingLoggingSystem(const std::string &header, const std::string &body) override;
private:
bool m_simple;
}; // class StringLogger }; // class StringLogger
} // namespace log } // namespace log
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment