summaryrefslogtreecommitdiff
path: root/indra/llcommon
diff options
context:
space:
mode:
authorNat Goodspeed <nat@lindenlab.com>2012-03-01 22:45:16 -0500
committerNat Goodspeed <nat@lindenlab.com>2012-03-01 22:45:16 -0500
commitcfe37cbfb5bdec0aa01c86a608ecc6cdc3df8a2a (patch)
tree382427c368637e771f8bb7125fc599a8913c6631 /indra/llcommon
parent0ef99cd33b4b450712e105e8ab448c2dab7081d2 (diff)
Break out std::ostream << CaptureLog routine for general use.
Diffstat (limited to 'indra/llcommon')
-rw-r--r--indra/llcommon/tests/wrapllerrs.h29
1 files changed, 20 insertions, 9 deletions
diff --git a/indra/llcommon/tests/wrapllerrs.h b/indra/llcommon/tests/wrapllerrs.h
index 10cf25b39e..a9c0c19c28 100644
--- a/indra/llcommon/tests/wrapllerrs.h
+++ b/indra/llcommon/tests/wrapllerrs.h
@@ -31,11 +31,11 @@
#include <tut/tut.hpp>
#include "llerrorcontrol.h"
+#include "stringize.h"
#include <boost/bind.hpp>
#include <list>
#include <string>
#include <stdexcept>
-#include <sstream>
// statically reference the function in test.cpp... it's short, we could
// replicate, but better to reuse
@@ -131,14 +131,9 @@ public:
if (! required)
return std::string();
- std::ostringstream out;
- out << "failed to find '" << search << "' in captured log messages:";
- for (MessageList::const_iterator mi(mMessages.begin()), mend(mMessages.end());
- mi != mend; ++mi)
- {
- out << '\n' << *mi;
- }
- throw tut::failure(out.str());
+ throw tut::failure(STRINGIZE("failed to find '" << search
+ << "' in captured log messages:\n"
+ << *this));
}
typedef std::list<std::string> MessageList;
@@ -146,4 +141,20 @@ public:
LLError::Settings* mOldSettings;
};
+std::ostream& operator<<(std::ostream& out, const CaptureLog& log)
+{
+ CaptureLog::MessageList::const_iterator mi(log.mMessages.begin()), mend(log.mMessages.end());
+ if (mi != mend)
+ {
+ // handle first message separately: it doesn't get a newline
+ out << *mi++;
+ for ( ; mi != mend; ++mi)
+ {
+ // every subsequent message gets a newline
+ out << '\n' << *mi;
+ }
+ }
+ return out;
+}
+
#endif /* ! defined(LL_WRAPLLERRS_H) */