-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLogger.cpp
More file actions
30 lines (27 loc) · 848 Bytes
/
Copy pathLogger.cpp
File metadata and controls
30 lines (27 loc) · 848 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#include "Logger.h"
int Logger::m_verbosityLevel = 0;
std::mutex Logger::m;
std::chrono::time_point<std::chrono::high_resolution_clock> Logger::startTime = std::chrono::high_resolution_clock::now();
std::string logTypeToStr(const LogType& type)
{
switch (type)
{
case LogType::WARNING:
return "Warning";
case LogType::INFO:
return "Info";
case LogType::ERROR:
return "Error";
default:
abort();
}
}
void Logger::Log(const std::string& module, const std::string& message, const int verbosity, const LogType& type)
{
if (verbosity <= m_verbosityLevel)
{
std::chrono::duration<double> time = std::chrono::high_resolution_clock::now() - startTime;
std::unique_lock<std::mutex> lk(m);
std::cout << "[" << logTypeToStr(type) << ", " << time.count() << "s] " << module << ": " << message << std::endl;
}
}