#include <TLog.hpp>
|
static void | setLevel (Level loglevel) |
|
static void | debug (const std::string &msg) |
|
static void | info (const std::string &msg) |
|
static void | warn (const std::string &msg) |
|
static void | error (const std::string &msg) |
|
static void | critical (const std::string &msg) |
|
Definition at line 21 of file TLog.hpp.
◆ Level
Enumerator |
---|
DEBUG | |
INFO | |
WARN | |
ERROR | |
CRITICAL | |
Definition at line 23 of file TLog.hpp.
◆ Logger() [1/2]
Definition at line 65 of file TLog.hpp.
66 mLogFile.open(
"log.txt", std::ofstream::trunc);
68 std::cerr <<
"ERROR:\tCould not open log file!" << std::endl;
◆ ~Logger()
tklb::Logger::~Logger |
( |
| ) |
|
|
inlineprivate |
Definition at line 72 of file TLog.hpp.
74 print(
"Shutting down...");
static void print(const char *msg, const Level level=Level::INFO)
◆ Logger() [2/2]
tklb::Logger::Logger |
( |
const Logger & |
| ) |
|
|
privatedelete |
◆ critical()
static void tklb::Logger::critical |
( |
const std::string & |
msg | ) |
|
|
inlinestatic |
Definition at line 107 of file TLog.hpp.
108 print(msg.c_str(), Level::CRITICAL);
◆ debug()
static void tklb::Logger::debug |
( |
const std::string & |
msg | ) |
|
|
inlinestatic |
Definition at line 89 of file TLog.hpp.
91 print(msg.c_str(), Level::DEBUG);
◆ error()
static void tklb::Logger::error |
( |
const std::string & |
msg | ) |
|
|
inlinestatic |
◆ info()
static void tklb::Logger::info |
( |
const std::string & |
msg | ) |
|
|
inlinestatic |
Definition at line 95 of file TLog.hpp.
96 print(msg.c_str(), Level::INFO);
◆ instance()
static Logger & tklb::Logger::instance |
( |
| ) |
|
|
inlinestaticprivate |
◆ operator=()
◆ print()
static void tklb::Logger::print |
( |
const char * |
msg, |
|
|
const Level |
level = Level::INFO |
|
) |
| |
|
inlinestaticprivate |
Definition at line 41 of file TLog.hpp.
43 if (level < inst.mLevel) {
return; }
45 const char* prefix =
nullptr;
46 if (level == Level::DEBUG) { prefix =
"DEBUG:"; }
47 if (level == Level::INFO) { prefix =
"INFO:"; }
48 if (level == Level::WARN) { prefix =
"WARN:"; }
49 if (level == Level::ERROR) { prefix =
"ERROR:"; }
50 if (level == Level::CRITICAL) { prefix =
"CRITICAL:"; }
52 if (level > Level::WARN) {
53 std::cerr << prefix <<
"\t" << msg << std::endl;
55 std::cout << prefix <<
"\t" << msg << std::endl;
58 if (!inst.mLogFile.is_open()) {
return; }
59 inst.mWriteLock.lock();
60 inst.mLogFile << prefix <<
"\t" << msg << std::endl;
61 inst.mLogFile.flush();
62 inst.mWriteLock.unlock();
static Logger & instance()
◆ setLevel()
static void tklb::Logger::setLevel |
( |
Level |
loglevel | ) |
|
|
inlinestatic |
◆ warn()
static void tklb::Logger::warn |
( |
const std::string & |
msg | ) |
|
|
inlinestatic |
Definition at line 99 of file TLog.hpp.
100 print(msg.c_str(), Level::WARN);
◆ mLevel
Level tklb::Logger::mLevel = Level::DEBUG |
|
private |
◆ mLogFile
std::ofstream tklb::Logger::mLogFile |
|
private |
◆ mWriteLock
std::mutex tklb::Logger::mWriteLock |
|
private |
The documentation for this class was generated from the following file: