#include <LogManager.h>
Public Member Functions | |
LogManager () | |
~LogManager () | |
void | AddLogCallback (LogCallback *callback) |
void | RemoveLogCallback (size_t index) |
void | RemoveAllByType (uint32 type) |
void | ClearLogCallbacks () |
LogCallback * | GetLogCallback (size_t index) |
size_t | FindLogCallback (LogCallback *callback) const |
size_t | GetNumLogCallbacks () const |
void | SetLogLevels (LogCallback::ELogLevel logLevels) |
MCORE_INLINE LogCallback::ELogLevel | GetLogLevels () const |
void | InitLogLevels () |
void | LogMessage (const char *message, LogCallback::ELogLevel logLevel=LogCallback::LOGLEVEL_INFO) |
Static Public Attributes | |
static Mutex | s_globalMutex |
The log manager handles the creation and retrieval of logs for the application. This class is responsible for managing the log callbacks and for logging. Each time you call the log function the manager will iterate through all log callbacks and call their Log() functions so that you can create and add your own log callbacks to the manager. This can be used to for instance log into your in-game console or to some mfc combo box.
MCore::LogManager::LogManager | ( | ) |
Default constructor.
MCore::LogManager::~LogManager | ( | ) |
Destructor.
void MCore::LogManager::AddLogCallback | ( | LogCallback * | callback | ) |
Add the given callback to the stack. Don't delete the callbacks yourself, the manager will keep track of the callbacks in the stack.
callback | The callback to add. |
void MCore::LogManager::ClearLogCallbacks | ( | ) |
Remove all log callbacks from the stack.
size_t MCore::LogManager::FindLogCallback | ( | LogCallback * | callback | ) | const |
Find the index of a given callback.
callback | The callback object to find. |
LogCallback * MCore::LogManager::GetLogCallback | ( | size_t | index | ) |
Return a pointer to the given log callback.
index | The index of the callback. |
|
inline |
Get the log levels any of the callbacks will accept and pass through. To check if a log level is enabled by one of the callbacks use logical bitwise and comparison, example: if (GetLogLevels() & LOGLEVEL_EXAMPLE).
size_t MCore::LogManager::GetNumLogCallbacks | ( | ) | const |
Return the number of log callbacks managed by this class.
void MCore::LogManager::InitLogLevels | ( | ) |
Iterate over all callbacks and collect the enabled log levels. This will automatically be called by the LogCallback::SetLogLevels() function. Do not call this function manually.
void MCore::LogManager::LogMessage | ( | const char * | message, |
LogCallback::ELogLevel | logLevel = LogCallback::LOGLEVEL_INFO |
||
) |
Log a message. This iterates through all callback instances and log to each of them.
message | The message to write into the log file. |
logLevel | The log message priority. |
void MCore::LogManager::RemoveAllByType | ( | uint32 | type | ) |
Remove all given log callbacks by type from the stack.
type | The type ID of the log callbacks to remove. |
void MCore::LogManager::RemoveLogCallback | ( | size_t | index | ) |
Remove the given callback from the stack.
index | The index of the callback to remove. |
void MCore::LogManager::SetLogLevels | ( | LogCallback::ELogLevel | logLevels | ) |
Force set the log levels of all callbacks in the log manager. To enable multiple log levels use the logical bitwise or operation, example: (LOGLEVEL_WARNING | LOGLEVEL_INFO).
logLevels | The log levels packed as bit flags which are enabled on the callbacks. |
|
static |
The multithread mutex, used by some global Log functions.