![]() |
CRM64Pro GDK v0.15.0
A free cross-platform game development kit built on top of SDL 3.0
|
Log Manager and Log objects for application and GDK message output [v26.02.0].
The Log module handles all logging output for both the client application and the GDK itself. The Log Manager handles the creation and destruction of Log objects and always owns a default log named "default" (although it is not initialized by default).
All CRM64Pro GDK modules use this default log for messages and information output. The client application can use the default log or create any number of additional Log objects.
The Log Manager always owns a default log named "default" with special characteristics:
| Initialization | Not initialized by default; call Log::init() to enable output |
|---|---|
| GDK usage | All CRM64Pro GDK modules output messages through this log |
| Release protection | Cannot be released; use Log::pause() to stop output |
When using LM_STDOUT, messages are automatically colored based on severity:
| LL_CRITICAL | Bold Magenta - Fatal errors / Crashes |
|---|---|
| LL_ERROR | Red - Runtime errors |
| LL_WARNING | Yellow - Undesirable states |
| LL_INFO | Default - Standard messages |
| LL_DEBUG | Cyan - Diagnostic information |
| LL_TRACE | Dark Gray - Low-level execution details |
An automatic error code logging mode is available when both conditions are met:
| GDK version | Link against a GDK debug version |
|---|---|
| Log level | Set eLogLevel to LL_DEBUG |
When enabled, all return error codes are automatically logged to the default log.
The log system supports automatic indentation management and prefix characters for organized output:
| Indentation | Use pushIndent()/popIndent() to manage automatic spacing |
|---|---|
| Prefix characters | Use setPrefix()/clearPrefix() to add block markers like "|" or ">>" |
| Combined usage | Combine prefix and indentation for clear hierarchical output |
This is a standard manager: objects are not shared and must be unique using its name as the key. You cannot create an object with the same name as another one already created.
Classes | |
| class | CRM64Pro::Log |
| Log Object class. More... | |
| class | CRM64Pro::LogMgr |
| Log Manager class. More... | |
Enumerations | |
| enum | CRM64Pro::eLogMode : Uint32 { CRM64Pro::LM_NULL = 0 , CRM64Pro::LM_FILE = 2 , CRM64Pro::LM_FILEAPPEND = 4 , CRM64Pro::LM_STDOUT = 8 , CRM64Pro::LM_CONSOLE = 16 , CRM64Pro::LM_RESERVED = 64 } |
| enum | CRM64Pro::eLogLevel { CRM64Pro::LL_OFF = 0 , CRM64Pro::LL_CRITICAL = 1 , CRM64Pro::LL_ERROR = 2 , CRM64Pro::LL_WARNING = 3 , CRM64Pro::LL_INFO = 4 , CRM64Pro::LL_DEBUG = 5 , CRM64Pro::LL_TRACE = 6 } |
| Log levels. More... | |
Functions | |
| bool | CRM64Pro::Log::info (Sint32 iMode=0) override |
| Request Log object information. | |
| const string & | CRM64Pro::Log::getName () const override |
| Get the name. | |
| Uint32 | CRM64Pro::Log::getID () const override |
| Get the ID. | |
| bool | CRM64Pro::Log::init (const string &sAppname, eLogLevel eLL, eLogMode eLM, const string &sFilename="", const string &sAuthor="", const string &sEmail="", const string &sWeb="") |
| Initialize the log object. | |
| bool | CRM64Pro::Log::pause () |
| Disable log output temporarily. | |
| bool | CRM64Pro::Log::resume () |
| Enable log output. | |
| eGeneralStatus | CRM64Pro::Log::status () const |
| Get log status. | |
| bool | CRM64Pro::Log::msg (eLogLevel eLL, const char *szFmt,...) |
| Write a message to the log. | |
| eLogLevel | CRM64Pro::Log::getLogLevel () |
| Get log detail level. | |
| eLogMode | CRM64Pro::Log::getLogMode () const |
| Get log mode. | |
| Sint32 | CRM64Pro::Log::setLogMode (eLogMode eLM, const string &sFilename="") |
| Set log mode. | |
| const string & | CRM64Pro::Log::getFilename () const |
| Get log filename. | |
| bool | CRM64Pro::Log::setTimeStamp (bool bEnabled) |
| Enable/disable timestamp in log messages. | |
| bool | CRM64Pro::Log::getTimeStamp () const |
| Get timestamp status. | |
| bool | CRM64Pro::Log::pushIndent (Sint32 iSpaces=2) |
| Push a new indentation level onto the stack. | |
| bool | CRM64Pro::Log::popIndent () |
| Pop the most recent indentation level from the stack. | |
| bool | CRM64Pro::Log::resetIndent () |
| Reset all indentation to zero. | |
| Sint32 | CRM64Pro::Log::getIndent () const |
| Get the current total indentation level. | |
| bool | CRM64Pro::Log::setPrefix (const char *szPrefix) |
| Set a prefix character to be printed before each message. | |
| bool | CRM64Pro::Log::clearPrefix () |
| Clear the prefix character. | |
| bool | CRM64Pro::LogMgr::info (Sint32 iMode=0) override |
| Request Log Manager information. | |
| Sint32 | CRM64Pro::LogMgr::create (const string &sName, Uint32 iUnused=0) override |
| Create a new log object. | |
| bool | CRM64Pro::LogMgr::close (Sint32 idLog) override |
| Close and destroy a log object. | |
| Sint32 | CRM64Pro::LogMgr::getCount () const override |
| Get number of loaded objects. | |
| Sint32 | CRM64Pro::LogMgr::setName (Sint32 idLog, const string &sName) override |
| Change the object name. | |
| Log * | CRM64Pro::LogMgr::get (Sint32 idLog=0) |
| Get a pointer to the log object. | |
| enum CRM64Pro::eLogMode : Uint32 |
Log output modes used in Log::init() and Log::setLogMode().
| Enumerator | |
|---|---|
| LM_NULL | Log output mode for the 'lm' parameter in CRM64Pro::Log::init(). Disable output entirely. |
| LM_FILE | Log output mode for the 'lm' parameter in CRM64Pro::Log::init(). Output to a file and overwrite existing content. |
| LM_FILEAPPEND | Log output mode for the 'lm' parameter in CRM64Pro::Log::init(). Output to a file, appending to existing content. |
| LM_STDOUT | Log output mode for the 'lm' parameter in CRM64Pro::Log::init(). Output to standard output (stdout). |
| LM_CONSOLE | Log output mode for the 'lm' parameter in CRM64Pro::Log::init(). Output to the integrated default console. |
| LM_RESERVED | Log output mode reserved for internal use; do not use it. |
| enum CRM64Pro::eLogLevel |
Log levels.
|
override |
Request Log object information.
Writes object information to the default log.
| iMode | unused for the time being. |
|
override |
Get the name.
|
override |
Get the ID.
| bool CRM64Pro::Log::init | ( | const string & | sAppname, |
| eLogLevel | eLL, | ||
| eLogMode | eLM, | ||
| const string & | sFilename = "", | ||
| const string & | sAuthor = "", | ||
| const string & | sEmail = "", | ||
| const string & | sWeb = "" ) |
Initialize the log object.
| sAppname | Name of your application. |
| eLL | Log verbosity threshold. Messages with a severity level numerically higher than this will be ignored. See ::eLogLevel. |
| eLM | Log mode. See ::LM_NULL, ::LM_STDOUT, ::LM_FILE, ::LM_FILEAPPEND and ::LM_CONSOLE. |
| sFilename | Name of log file. Only used with ::LM_FILE or ::LM_FILEAPPEND. Directory separators '\' and '/' are supported. |
| sAuthor | Author name. |
| sEmail | Author email address. |
| sWeb | Author web site. |
| bool CRM64Pro::Log::pause | ( | ) |
Disable log output temporarily.
Temporarily disables log output.
| bool CRM64Pro::Log::resume | ( | ) |
Enable log output.
Re-enables log output.
| eGeneralStatus CRM64Pro::Log::status | ( | ) | const |
Get log status.
| bool CRM64Pro::Log::msg | ( | eLogLevel | eLL, |
| const char * | szFmt, | ||
| ... ) |
Write a message to the log.
| eLL | Severity level of the message. The message is logged only if this value is less than or equal to the verbosity set in init(). See ::eLogLevel. |
| szFmt | A printf() style message format string. |
| ... | Variable arguments for format string. |
| eLogLevel CRM64Pro::Log::getLogLevel | ( | ) |
Get log detail level.
| eLogMode CRM64Pro::Log::getLogMode | ( | ) | const |
Get log mode.
| Sint32 CRM64Pro::Log::setLogMode | ( | eLogMode | eLM, |
| const string & | sFilename = "" ) |
Set log mode.
| eLM | log mode. See ::LM_NULL, ::LM_STDOUT, ::LM_FILE, ::LM_FILEAPPEND and ::LM_CONSOLE. |
| sFilename | name of log file (only relevant with ::LM_FILE or ::LM_FILEAPPEND). Directory separators '\' and '/' are supported. |
| const string & CRM64Pro::Log::getFilename | ( | ) | const |
Get log filename.
| bool CRM64Pro::Log::setTimeStamp | ( | bool | bEnabled | ) |
Enable/disable timestamp in log messages.
Disabled by default. Only works with ::LM_FILE or ::LM_FILEAPPEND modes. Does not display timestamps in console output.
| bEnabled | true to enable or false to disable. |
| bool CRM64Pro::Log::getTimeStamp | ( | ) | const |
Get timestamp status.
| bool CRM64Pro::Log::pushIndent | ( | Sint32 | iSpaces = 2 | ) |
Push a new indentation level onto the stack.
Increases the current indentation by the specified number of spaces. Each call to pushIndent() should be paired with a corresponding popIndent(). Indentation is cumulative: multiple pushIndent() calls will add their spaces together.
| iSpaces | Number of spaces to add to the current indentation level (default: 2). |
| bool CRM64Pro::Log::popIndent | ( | ) |
Pop the most recent indentation level from the stack.
Decreases the current indentation by removing the last pushed indent level. Should be called to match each pushIndent() call.
| bool CRM64Pro::Log::resetIndent | ( | ) |
Reset all indentation to zero.
Clears the entire indentation stack and resets current indentation to 0. Useful for recovering from mismatched push/pop calls or resetting state.
| Sint32 CRM64Pro::Log::getIndent | ( | ) | const |
Get the current total indentation level.
Returns the sum of all active indentation levels (total spaces).
| bool CRM64Pro::Log::setPrefix | ( | const char * | szPrefix | ) |
Set a prefix character to be printed before each message.
| szPrefix | String to print at the beginning of each message (e.g., "|", ">>", etc.). The prefix appears before indentation. |
| bool CRM64Pro::Log::clearPrefix | ( | ) |
Clear the prefix character.
|
override |
Request Log Manager information.
Writes manager information to the default log.
| iMode | -1 to display only manager information. 0 (default) to display manager and all objects. Specific object ID to display manager and only that object. |
|
override |
Create a new log object.
| sName | name for the log object (e.g. 'myLog'). Must be unique; longer names are truncated to 64 characters. |
| iUnused | unused for the time being. |
|
override |
Close and destroy a log object.
| idLog | 0 to close all logs, or a specific log id. The default log cannot be removed with this method. |
|
override |
Get number of loaded objects.
|
override |
Change the object name.
| idLog | Log id. |
| sName | new name (e.g. 'myLog'). Must be unique; longer names are truncated to 64 characters. |