+/**
+ * Stores the logging messages in a line sequence, inclusive the location as tag.
+ * This allows the retrieval whether a given error message is stored.
+ */
+class ReTestMemoryAppender: public ReMemoryAppender {
+public:
+ ReTestMemoryAppender() :
+ ReMemoryAppender(1000) {
+ // with 24 bit tag, 16-bit linecount
+ setSizes(3, 2);
+ }
+public:
+ bool contains(const char* message, bool ignoreCase = true);
+ bool containsLocation(int location);
+ virtual void say(ReLogger* logger, const char* message);
+};
+/**
+ * Tests whether the stored logging messages contains a given message.
+ *
+ * @param message message to search
+ * @param ignoreCase <code>true</code>: the search is case insensitive
+ * @return <code>true</code>: the message is stored<br>
+ * <code>false</code>: otherwise
+ */
+bool ReTestMemoryAppender::contains(const char* message, bool ignoreCase) {
+ ReByteArray line;
+ bool rc = false;
+ for (size_t ix = 0; !rc && ix < count(); ix++) {
+ get(ix, line);
+ rc = line.indexOf(message, -1, 0, -1, ignoreCase) >= 0;
+ }
+ return rc;
+}
+/**
+ * Tests whether the stored logging messages contains a given location.
+ *
+ * @param location location to search
+ * @return <code>true</code>: the location is stored<br>
+ * <code>false</code>: otherwise
+ */
+bool ReTestMemoryAppender::containsLocation(int location) {
+ ReByteArray line;
+ ReSeqArray::Tag tag;
+ bool rc = false;
+ for (size_t ix = 0; !rc && ix < count(); ix++) {
+ get(ix, line, &tag);
+ rc = tag == location;
+ }
+ return rc;
+}
+
+/**
+ * Stores a logging message.
+ *
+ * Distinction to ReMemoryAppender::say(): the location is stored as tag.
+ * This enables an easy retrieval.
+ *
+ * @param logger the caller
+ * @param message the logging message to store
+ */
+void ReTestMemoryAppender::say(ReLogger* logger, const char* message) {
+ int theCount = count();
+ if (theCount >= m_maxLines)
+ remove(theCount - 1);
+ // we store in reverse order:
+ add(0, message != NULL ? message : logger->asCString(), -1,
+ logger->currentLocation());
+}
+