keyboard stuff
1/* Copyright 2021 Stefan Kerkmann
2 *
3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17#include <iomanip>
18#include <iostream>
19#include "test_logger.hpp"
20#include "timer.h"
21
22TestLogger test_logger;
23
24TestLogger& TestLogger::info() {
25 *this << "[ INFO ] ";
26 return this->timestamp();
27}
28
29TestLogger& TestLogger::trace() {
30 *this << "[ TRACE ] ";
31 return this->timestamp();
32}
33
34TestLogger& TestLogger::error() {
35 *this << "[ ERROR ] ";
36 return this->timestamp();
37}
38
39TestLogger& TestLogger::timestamp() {
40 *this << std::setw(6) << timer_read32() << " ";
41 return *this;
42}
43void TestLogger::reset() {
44 this->m_log.str("");
45};
46
47void TestLogger::print_header() {
48 std::cerr << "[ LEVEL ] [TIME] [EVENT]" << std::endl;
49}
50
51void TestLogger::print_log() {
52 std::cerr << this->m_log.str();
53}