diff --git a/include/GLog.hpp b/include/GLog.hpp index e743c62..3d99ffc 100644 --- a/include/GLog.hpp +++ b/include/GLog.hpp @@ -1,7 +1,7 @@ /*************************************************************************** * GLog.hpp - Information logger * * ----------------------------------------------------------------------- * - * copyright (C) 2010-2016 by Juergen Knoedlseder * + * copyright (C) 2010-2017 by Juergen Knoedlseder * * ----------------------------------------------------------------------- * * * * This program is free software: you can redistribute it and/or modify * @@ -121,7 +121,7 @@ protected: void header(const std::string& arg, int level); std::string strdate(void) const; std::string prefix(void) const; - void append(std::string arg); + void append(const std::string& string); // Protected data members int m_max_length; //!< Maximum buffer length diff --git a/src/app/GLog.cpp b/src/app/GLog.cpp index 19d2ce6..f77cb41 100644 --- a/src/app/GLog.cpp +++ b/src/app/GLog.cpp @@ -802,13 +802,16 @@ std::string GLog::prefix(void) const /***********************************************************************//** * @brief Append string to the buffer * - * @param[in] arg String to append + * @param[in] string String to append * * This method appends a string to the buffer and prepends, if required, the * current date and name at the beginning of each line. ***************************************************************************/ -void GLog::append(std::string arg) +void GLog::append(const std::string& string) { + // Copy string to append + std::string arg = string; + // If the buffer is empty and at the beginning of a line or if the last // character is a \n then prepend a prefix at the beginning of the string // to be inserted.