-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added logger Switched to C++20 Fixes #6
- Loading branch information
Showing
7 changed files
with
122 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#include "logger.hpp" | ||
#include <mutex> | ||
#include <iostream> | ||
|
||
|
||
std::mutex loggerMutex; | ||
|
||
void LoggerBogger::Log(LogLevel level, const std::string& msg) | ||
{ | ||
if (level == LogLevel::Verbose && !m_EnableVerbose) | ||
return; | ||
|
||
std::lock_guard m(loggerMutex); | ||
|
||
std::cout << msg.c_str() << "\n"; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#pragma once | ||
#include <string> | ||
|
||
enum class LogLevel | ||
{ | ||
Normal, | ||
Verbose | ||
}; | ||
|
||
class LoggerBogger // Weird name because SQF-VM also has class Logger, without namespace (most of its stuff is in namespace, just not that) | ||
{ | ||
public: | ||
//#TODO in-place formatting, vsnprintf | ||
//#TODO multithreading queue instead of locking | ||
|
||
//! This function might be hit by multiple threads | ||
void Log(LogLevel level, const std::string& msg); | ||
|
||
bool m_EnableVerbose = false; | ||
}; | ||
|
||
inline LoggerBogger GLogger; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters