Commit ac099315d2206c9e0cccd3967a302809dd67fef4

Authored by Jürgen Knödlseder
1 parent 7965594e

The GLog::append method now works on a copy of the argument and not the argument itself.

include/GLog.hpp
1 1 /***************************************************************************
2 2 * GLog.hpp - Information logger *
3 3 * ----------------------------------------------------------------------- *
4   - * copyright (C) 2010-2016 by Juergen Knoedlseder *
  4 + * copyright (C) 2010-2017 by Juergen Knoedlseder *
5 5 * ----------------------------------------------------------------------- *
6 6 * *
7 7 * This program is free software: you can redistribute it and/or modify *
... ... @@ -121,7 +121,7 @@ protected:
121 121 void header(const std::string& arg, int level);
122 122 std::string strdate(void) const;
123 123 std::string prefix(void) const;
124   - void append(std::string arg);
  124 + void append(const std::string& string);
125 125  
126 126 // Protected data members
127 127 int m_max_length; //!< Maximum buffer length
... ...
src/app/GLog.cpp
... ... @@ -802,13 +802,16 @@ std::string GLog::prefix(void) const
802 802 /***********************************************************************//**
803 803 * @brief Append string to the buffer
804 804 *
805   - * @param[in] arg String to append
  805 + * @param[in] string String to append
806 806 *
807 807 * This method appends a string to the buffer and prepends, if required, the
808 808 * current date and name at the beginning of each line.
809 809 ***************************************************************************/
810   -void GLog::append(std::string arg)
  810 +void GLog::append(const std::string& string)
811 811 {
  812 + // Copy string to append
  813 + std::string arg = string;
  814 +
812 815 // If the buffer is empty and at the beginning of a line or if the last
813 816 // character is a \n then prepend a prefix at the beginning of the string
814 817 // to be inserted.
... ...