|
Botcraft 1.21.10
|
#include <Logger.hpp>
Public Member Functions | |
| Logger (const Logger &)=delete | |
| Logger & | operator= (const Logger &)=delete |
| Logger (Logger &&)=delete | |
| Logger & | operator= (Logger &&)=delete |
| ~Logger () | |
| void | Log (const std::string &s) |
| void | SetFilename (const std::string &s) |
| void | SetLogLevel (const LogLevel l) |
| LogLevel | GetLogLevel () const |
| void | SetLogFunc (const std::function< void(const std::string &)> &f) |
| std::stringstream | GetDate () const |
| void | RegisterThread (const std::string &name) |
| Register the current thread in the map. | |
| void | RegisterThread (const std::thread::id id, const std::string &name) |
| Register a thread in the map. | |
| std::string | GetThreadName (const std::thread::id id) |
| Get the name of a given thread. | |
| void | UnregisterThread (const std::thread::id id) |
| Remove a thread from the map. | |
Static Public Member Functions | |
| static Logger & | GetInstance () |
Static Public Attributes | |
| static constexpr std::array< std::string_view, static_cast< size_t >(LogLevel::NUM_LOG_LEVEL)+1 > | level_strings |
Private Member Functions | |
| Logger () | |
Private Attributes | |
| std::mutex | mutex |
| std::string | filename |
| std::atomic< LogLevel > | log_level |
| std::function< void(const std::string &)> | log_func |
| std::chrono::steady_clock::time_point | last_time_logged |
| std::string | file_buffer |
| std::mutex | thread_mutex |
| std::unordered_map< std::thread::id, std::string > | thread_names |
Definition at line 64 of file Logger.hpp.
|
private |
Definition at line 12 of file Logger.cpp.
References file_buffer, filename, Botcraft::Info, last_time_logged, log_func, and log_level.
|
delete |
|
delete |
| Botcraft::Logger::~Logger | ( | ) |
Definition at line 25 of file Logger.cpp.
References file_buffer, filename, and mutex.
| std::stringstream Botcraft::Logger::GetDate | ( | ) | const |
Definition at line 84 of file Logger.cpp.
|
static |
Definition at line 36 of file Logger.cpp.
Referenced by Botcraft::PhysicsManager::Physics(), Botcraft::Renderer::RenderingManager::Run(), Botcraft::TCP_Com::TCP_Com(), Botcraft::TemplatedBehaviourClient< TDerived >::TreeLoop(), Botcraft::NetworkManager::WaitForNewPackets(), Botcraft::Renderer::RenderingManager::WaitForRenderingUpdate(), and Botcraft::TCP_Com::~TCP_Com().
| LogLevel Botcraft::Logger::GetLogLevel | ( | ) | const |
Definition at line 73 of file Logger.cpp.
References log_level.
| std::string Botcraft::Logger::GetThreadName | ( | const std::thread::id | id | ) |
Get the name of a given thread.
| id | Thread id |
Definition at line 124 of file Logger.cpp.
References thread_mutex, and thread_names.
| void Botcraft::Logger::Log | ( | const std::string & | s | ) |
Definition at line 42 of file Logger.cpp.
References file_buffer, filename, last_time_logged, log_func, and mutex.
| void Botcraft::Logger::RegisterThread | ( | const std::string & | name | ) |
Register the current thread in the map.
It will be automatically removed on thread exit.
| name | Thread name |
Definition at line 104 of file Logger.cpp.
References thread_mutex, and thread_names.
Referenced by Botcraft::PhysicsManager::Physics(), Botcraft::Renderer::RenderingManager::Run(), Botcraft::TCP_Com::TCP_Com(), Botcraft::TemplatedBehaviourClient< TDerived >::TreeLoop(), Botcraft::NetworkManager::WaitForNewPackets(), and Botcraft::Renderer::RenderingManager::WaitForRenderingUpdate().
| void Botcraft::Logger::RegisterThread | ( | const std::thread::id | id, |
| const std::string & | name | ||
| ) |
Register a thread in the map.
It will NOT be automatically removed on thread exit.
| id | Thread id |
| name | Thread name |
Definition at line 118 of file Logger.cpp.
References thread_mutex, and thread_names.
| void Botcraft::Logger::SetFilename | ( | const std::string & | s | ) |
Definition at line 62 of file Logger.cpp.
| void Botcraft::Logger::SetLogFunc | ( | const std::function< void(const std::string &)> & | f | ) |
Definition at line 78 of file Logger.cpp.
| void Botcraft::Logger::SetLogLevel | ( | const LogLevel | l | ) |
Definition at line 68 of file Logger.cpp.
References log_level.
| void Botcraft::Logger::UnregisterThread | ( | const std::thread::id | id | ) |
Remove a thread from the map.
| id | Thread id |
Definition at line 130 of file Logger.cpp.
References thread_mutex, and thread_names.
Referenced by Botcraft::TCP_Com::~TCP_Com().
|
private |
Definition at line 119 of file Logger.hpp.
|
private |
Definition at line 114 of file Logger.hpp.
Referenced by Log(), Logger(), SetFilename(), and ~Logger().
|
private |
Definition at line 118 of file Logger.hpp.
|
staticconstexpr |
Definition at line 69 of file Logger.hpp.
|
private |
Definition at line 116 of file Logger.hpp.
Referenced by Log(), Logger(), and SetLogFunc().
|
private |
Definition at line 115 of file Logger.hpp.
Referenced by GetLogLevel(), Logger(), and SetLogLevel().
|
private |
Definition at line 113 of file Logger.hpp.
Referenced by Log(), SetFilename(), SetLogFunc(), and ~Logger().
|
private |
Definition at line 121 of file Logger.hpp.
Referenced by GetThreadName(), RegisterThread(), RegisterThread(), and UnregisterThread().
|
private |
Definition at line 122 of file Logger.hpp.
Referenced by GetThreadName(), RegisterThread(), RegisterThread(), and UnregisterThread().