mmCEsim 0.3.0
mmWave Channel Estimation Simulation
log.h
Go to the documentation of this file.
1
12#ifndef _LOG_H_
13#define _LOG_H_
14
15#include "meta.h"
16#include "term.h"
17#include "utils.h"
18#include <ctime>
19#include <filesystem>
20#include <fstream>
21#include <iomanip>
22#include <spy.hpp>
23
28class Log {
29
30 public:
37 Log();
38
44 ~Log();
45
51 std::ofstream& write();
52
59 std::ofstream& info();
60
67 std::ofstream& war();
68
75 std::ofstream& err();
76
83 std::ofstream& msg();
84
90 void flush();
91
98 void writeArg(int argc, char* argv[]);
99
100 private:
101 std::ofstream _f;
102 bool _open = false;
103};
104
105inline std::ofstream& Log::write() { return _f; }
106
107inline std::ofstream& Log::info() {
108 _f << "[INFO] ";
109 return _f;
110}
111
112inline std::ofstream& Log::war() {
113 _f << "[WARNING] ";
114 return _f;
115}
116
117inline std::ofstream& Log::err() {
118 _f << "[ERROR] ";
119 return _f;
120}
121
122inline std::ofstream& Log::msg() {
123 _f << "[MESSAGE] ";
124 return _f;
125}
126
127inline void Log::flush() { _f << std::flush; }
128
129#endif
Log support during compilation.
Definition: log.h:28
~Log()
Destroy the Log object.
Definition: log.cpp:42
std::ofstream & write()
Write contents to the log file.
Definition: log.h:105
std::ofstream _f
output file stream
Definition: log.h:101
void flush()
Flush the buff into the log file.
Definition: log.h:127
bool _open
whether the file successfully opened
Definition: log.h:102
void writeArg(int argc, char *argv[])
Write CLI arguments information to log.
Definition: log.cpp:46
std::ofstream & msg()
Write a message to the log file.
Definition: log.h:122
std::ofstream & war()
Write warning message to the log file.
Definition: log.h:112
std::ofstream & err()
Write error message to the log file.
Definition: log.h:117
std::ofstream & info()
Write infomation to the log file.
Definition: log.h:107
Log()
Construct a new Log object.
Definition: log.cpp:27
mmCEsim meta data
Terminal Color and Style Control.
Utilities.