summary refs log tree commit diff
path: root/tests/test_common/test_logger.cpp
diff options
context:
space:
mode:
authorStefan Kerkmann <karlk90@pm.me>2022-12-14 16:31:08 +0100
committerGitHub <noreply@github.com>2022-12-15 02:31:08 +1100
commit962e4c0e1854b10612bab547c3d842c5f967dd23 (patch)
treedfe13a5a7d3f593452a1e77b5c4173263d3fb2e2 /tests/test_common/test_logger.cpp
parente2ab98f9601049a7540bd89cb128669b09c688d5 (diff)
[Test] Reset timer for every unit test and provide timestamps for log messages (#17028)
Diffstat (limited to 'tests/test_common/test_logger.cpp')
-rw-r--r--tests/test_common/test_logger.cpp16
1 files changed, 13 insertions, 3 deletions
diff --git a/tests/test_common/test_logger.cpp b/tests/test_common/test_logger.cpp
index efc7719d13..0ff4e686ee 100644
--- a/tests/test_common/test_logger.cpp
+++ b/tests/test_common/test_logger.cpp
@@ -14,30 +14,40 @@
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
+#include <iomanip>
 #include <iostream>
 #include "test_logger.hpp"
+#include "timer.h"
 
 TestLogger test_logger;
 
 TestLogger& TestLogger::info() {
     *this << "[ INFO     ] ";
-    return *this;
+    return this->timestamp();
 }
 
 TestLogger& TestLogger::trace() {
     *this << "[ TRACE    ] ";
-    return *this;
+    return this->timestamp();
 }
 
 TestLogger& TestLogger::error() {
     *this << "[ ERROR    ] ";
-    return *this;
+    return this->timestamp();
 }
 
+TestLogger& TestLogger::timestamp() {
+    *this << std::setw(6) << timer_read32() << " ";
+    return *this;
+}
 void TestLogger::reset() {
     this->m_log.str("");
 };
 
+void TestLogger::print_header() {
+    std::cerr << "[ LEVEL    ] [TIME] [EVENT]" << std::endl;
+}
+
 void TestLogger::print_log() {
     std::cerr << this->m_log.str();
 }