diff options
| author | Stefan Kerkmann <karlk90@pm.me> | 2022-12-14 16:31:08 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-12-15 02:31:08 +1100 |
| commit | 962e4c0e1854b10612bab547c3d842c5f967dd23 (patch) | |
| tree | dfe13a5a7d3f593452a1e77b5c4173263d3fb2e2 /tests/test_common/test_logger.cpp | |
| parent | e2ab98f9601049a7540bd89cb128669b09c688d5 (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.cpp | 16 |
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 @@ | |||
| 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 15 | */ | 15 | */ |
| 16 | 16 | ||
| 17 | #include <iomanip> | ||
| 17 | #include <iostream> | 18 | #include <iostream> |
| 18 | #include "test_logger.hpp" | 19 | #include "test_logger.hpp" |
| 20 | #include "timer.h" | ||
| 19 | 21 | ||
| 20 | TestLogger test_logger; | 22 | TestLogger test_logger; |
| 21 | 23 | ||
| 22 | TestLogger& TestLogger::info() { | 24 | TestLogger& TestLogger::info() { |
| 23 | *this << "[ INFO ] "; | 25 | *this << "[ INFO ] "; |
| 24 | return *this; | 26 | return this->timestamp(); |
| 25 | } | 27 | } |
| 26 | 28 | ||
| 27 | TestLogger& TestLogger::trace() { | 29 | TestLogger& TestLogger::trace() { |
| 28 | *this << "[ TRACE ] "; | 30 | *this << "[ TRACE ] "; |
| 29 | return *this; | 31 | return this->timestamp(); |
| 30 | } | 32 | } |
| 31 | 33 | ||
| 32 | TestLogger& TestLogger::error() { | 34 | TestLogger& TestLogger::error() { |
| 33 | *this << "[ ERROR ] "; | 35 | *this << "[ ERROR ] "; |
| 34 | return *this; | 36 | return this->timestamp(); |
| 35 | } | 37 | } |
| 36 | 38 | ||
| 39 | TestLogger& TestLogger::timestamp() { | ||
| 40 | *this << std::setw(6) << timer_read32() << " "; | ||
| 41 | return *this; | ||
| 42 | } | ||
| 37 | void TestLogger::reset() { | 43 | void TestLogger::reset() { |
| 38 | this->m_log.str(""); | 44 | this->m_log.str(""); |
| 39 | }; | 45 | }; |
| 40 | 46 | ||
| 47 | void TestLogger::print_header() { | ||
| 48 | std::cerr << "[ LEVEL ] [TIME] [EVENT]" << std::endl; | ||
| 49 | } | ||
| 50 | |||
| 41 | void TestLogger::print_log() { | 51 | void TestLogger::print_log() { |
| 42 | std::cerr << this->m_log.str(); | 52 | std::cerr << this->m_log.str(); |
| 43 | } | 53 | } |
