CRM64Pro GDK v0.13.0
A free cross-platform game development kit built on top of SDL 3.0
Loading...
Searching...
No Matches

Description

Log Manager and Log objects for application and GDK message output [v25.12.0].

Overview

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.

Key features

  • Default log: Built-in "default" log used by all GDK modules
  • Multiple logs: Create additional Log objects for application-specific output
  • Pause control: Stop and resume log output without releasing the log
  • Debug mode: Automatic error code logging when using GDK debug builds

Default log

The Log Manager always owns a default log named "default" with special characteristics:

InitializationNot initialized by default; call Log::init() to enable output
GDK usageAll CRM64Pro GDK modules output messages through this log
Release protectionCannot be released; use Log::pause() to stop output

Debug mode logging

An automatic error code logging mode is available when both conditions are met:

GDK versionLink against a GDK debug version
Log levelSet eLogLevel to LL_HIGH


When enabled, all return error codes are automatically logged to the default log.

Manager type

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.

Best practices

  • Initialize the default log using Log::init() right after Main::Instance() to capture all GDK initialization messages
  • Use Log::pause() instead of releasing when you need to temporarily stop default log output
  • Create separate Log objects for different application subsystems to organize output
  • Use debug builds with LL_HIGH log level during development for comprehensive error tracking
  • Ensure each custom log has a unique name before creation
  • Access the manager exclusively through Main::ILogMgr()
Note
The Log Manager and default Log are singletons, automatically created once Main is instantiated. You can get a reference to this manager using Main::ILogMgr() method.
The Log Manager is automatically released when Main::Terminate() is called. At this time, any resource still loaded will be released, avoiding resource leaks.

Classes

class  CRM64Pro::Log
 Log Object class. More...
class  CRM64Pro::LogMgr
 Log Manager class. More...

Macros

#define LM_NULL   0
#define LM_FILE   2
#define LM_FILEAPPEND   4
#define LM_STDOUT   8
#define LM_CONSOLE   16
#define LM_RESERVED   64

Enumerations

enum  CRM64Pro::eLogLevel { CRM64Pro::LL_LOW = 0 , CRM64Pro::LL_NORMAL = 4 , CRM64Pro::LL_HIGH = 16 }
 Log verbosity. More...
enum  CRM64Pro::eLogMessageLevel {
  CRM64Pro::LML_CRITICAL = 0 , CRM64Pro::LML_NORMAL = 4 , CRM64Pro::LML_LOW = 16 , CRM64Pro::LML_INFO = 64 ,
  CRM64Pro::LML_NULL = 128
}
 Importance of a logged message. More...

Functions

Sint32 CRM64Pro::Log::info (Sint32 iMode=0)
 Request Log object information.
Sint32 CRM64Pro::Log::getName (string &sName)
 Get the name.
Uint32 CRM64Pro::Log::getID ()
 Get the ID.
Sint32 CRM64Pro::Log::init (const string &sAppname, eLogLevel eLL, Sint32 iLM, const string &sFilename="", const string &sAuthor="", const string &sEmail="", const string &sWeb="")
 Initialize the log object.
Sint32 CRM64Pro::Log::pause ()
 Disable log output temporarily.
Sint32 CRM64Pro::Log::resume ()
 Enable log output.
Sint32 CRM64Pro::Log::status ()
 Get log status.
Sint32 CRM64Pro::Log::msg (eLogMessageLevel eLML, const char *szFmt,...)
 Write a message to the log.
eLogLevel CRM64Pro::Log::getLogLevel ()
 Get log detail level.
Sint32 CRM64Pro::Log::getLogMode ()
 Get log mode.
Sint32 CRM64Pro::Log::setLogMode (Sint32 iLM, const string &sFilename="")
 Set log mode.
Sint32 CRM64Pro::Log::getFilename (string &sName)
 Get log filename.
Sint32 CRM64Pro::Log::setTimeStamp (Sint32 iM)
 Enable/disable timestamp in log messages.
Sint32 CRM64Pro::Log::getTimeStamp ()
 Get timestamp status.
Sint32 CRM64Pro::LogMgr::info (Sint32 iMode=0)
 Request Log Manager information.
Sint32 CRM64Pro::LogMgr::create (const string &sName, Uint32 iUnused=0)
 Create a new log object.
Sint32 CRM64Pro::LogMgr::close (Sint32 idLog)
 Close and destroy a log object.
Sint32 CRM64Pro::LogMgr::getNum () const
 Get number of loaded objects.
Sint32 CRM64Pro::LogMgr::setName (Sint32 idLog, const string &sName)
 Change the object name.
LogCRM64Pro::LogMgr::get (Sint32 idLog=0)
 Get a pointer to the log object.

Macro Definition Documentation

◆ LM_NULL

#define LM_NULL   0

Log output mode for the 'lm' parameter in CRM64Pro::Log::init(). Disable output entirely.

◆ LM_FILE

#define LM_FILE   2

Log output mode for the 'lm' parameter in CRM64Pro::Log::init(). Output to a file and overwrite existing content.

◆ LM_FILEAPPEND

#define LM_FILEAPPEND   4

Log output mode for the 'lm' parameter in CRM64Pro::Log::init(). Output to a file, appending to existing content.

◆ LM_STDOUT

#define LM_STDOUT   8

Log output mode for the 'lm' parameter in CRM64Pro::Log::init(). Output to standard output (stdout).

◆ LM_CONSOLE

#define LM_CONSOLE   16

Log output mode for the 'lm' parameter in CRM64Pro::Log::init(). Output to the integrated default console.

◆ LM_RESERVED

#define LM_RESERVED   64

Log output mode reserved for internal use; do not use it.

Enumeration Type Documentation

◆ eLogLevel

Log verbosity.

Enumerator
LL_LOW 

'll' parameter in Log::init(). Logs ::LML_CRITICAL and ::LML_INFO messages only.

LL_NORMAL 

'll' parameter in Log::init(). Adds ::LML_NORMAL messages.

LL_HIGH 

'll' parameter in Log::init(). Adds ::LML_LOW messages.

◆ eLogMessageLevel

Importance of a logged message.

Enumerator
LML_CRITICAL 

'lml' parameter in Log::msg(). Logged on all log levels. Use for critical errors.

LML_NORMAL 

'lml' parameter in Log::msg(). Logged on ::LL_NORMAL and ::LL_HIGH. Use for errors and warnings.

LML_LOW 

'lml' parameter in Log::msg(). Logged on ::LL_HIGH. Use for warnings and debugging messages.

LML_INFO 

'lml' parameter in Log::msg(). Logged on all log levels. Timestamp not supported. Use for informational messages.

LML_NULL 

'lml' parameter in Log::msg(). Do not log anything.

Function Documentation

◆ info() [1/2]

Sint32 CRM64Pro::Log::info ( Sint32 iMode = 0)

Request Log object information.

Writes object information to the default log.

Parameters
iModeunused for the time being.
Returns
0 on success, or a negative error code on failure.

◆ getName()

Sint32 CRM64Pro::Log::getName ( string & sName)

Get the name.

Parameters
sNamestring containing the log name.
Returns
0 on success, or a negative error code on failure.

◆ getID()

Uint32 CRM64Pro::Log::getID ( )

Get the ID.

Returns
Object ID.

◆ init()

Sint32 CRM64Pro::Log::init ( const string & sAppname,
eLogLevel eLL,
Sint32 iLM,
const string & sFilename = "",
const string & sAuthor = "",
const string & sEmail = "",
const string & sWeb = "" )

Initialize the log object.

Parameters
sAppnamename of your application.
eLLlog verbosity. See ::eLogLevel.
iLMlog mode. See LM_NULL, LM_STDOUT, LM_FILE, LM_FILEAPPEND and LM_CONSOLE.
sFilenamename of log file. Only used with LM_FILE or LM_FILEAPPEND. Directory separators '\' and '/' are supported.
sAuthorauthor name.
sEmailauthor email address.
sWebauthor web site.
Returns
0 on success, or a negative error code on failure.

◆ pause()

Sint32 CRM64Pro::Log::pause ( )

Disable log output temporarily.

Temporarily disables log output.

Returns
0 on success, or a negative error code on failure.

◆ resume()

Sint32 CRM64Pro::Log::resume ( )

Enable log output.

Re-enables log output.

Returns
0 on success, or a negative error code on failure.

◆ status()

Sint32 CRM64Pro::Log::status ( )

Get log status.

Returns
C64_STATUS_DISABLED if output is disabled, or C64_STATUS_ENABLED if output is enabled (actual output depends on log mode).

◆ msg()

Sint32 CRM64Pro::Log::msg ( eLogMessageLevel eLML,
const char * szFmt,
... )

Write a message to the log.

Parameters
eLMLimportance of the message. See ::eLogMessageLevel.
szFmta printf() style message format string.
Returns
0 on success, or a negative error code on failure.

◆ getLogLevel()

eLogLevel CRM64Pro::Log::getLogLevel ( )

Get log detail level.

Returns
Current log verbosity. See ::eLogLevel.

◆ getLogMode()

Sint32 CRM64Pro::Log::getLogMode ( )

Get log mode.

Returns
Current log mode. See LM_NULL, LM_STDOUT, LM_FILE, LM_FILEAPPEND and LM_CONSOLE.

◆ setLogMode()

Sint32 CRM64Pro::Log::setLogMode ( Sint32 iLM,
const string & sFilename = "" )

Set log mode.

Parameters
iLMlog mode. See LM_NULL, LM_STDOUT, LM_FILE, LM_FILEAPPEND and LM_CONSOLE.
sFilenamename of log file (only relevant with LM_FILE or LM_FILEAPPEND). Directory separators '\' and '/' are supported.
Returns
0 on success, or a negative error code on failure.

◆ getFilename()

Sint32 CRM64Pro::Log::getFilename ( string & sName)

Get log filename.

Parameters
sNamestring filled with the current filename.
Returns
0 on success, or a negative error code on failure.

◆ setTimeStamp()

Sint32 CRM64Pro::Log::setTimeStamp ( Sint32 iM)

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.

Parameters
iM0 to disable or any other value to enable.
Returns
0 on success, or a negative error code on failure.

◆ getTimeStamp()

Sint32 CRM64Pro::Log::getTimeStamp ( )

Get timestamp status.

Returns
0 if it is disabled or any other value if it is enabled.

◆ info() [2/2]

Sint32 CRM64Pro::LogMgr::info ( Sint32 iMode = 0)

Request Log Manager information.

Writes manager information to the default log.

Parameters
iMode-1 to display only manager information. 0 (default) to include manager and all objects.
Returns
0 on success, or a negative error code on failure.

◆ create()

Sint32 CRM64Pro::LogMgr::create ( const string & sName,
Uint32 iUnused = 0 )

Create a new log object.

Parameters
sNamename for the log object (e.g. 'myLog'). Must be unique; longer names are truncated to 64 characters.
iUnusedunused for the time being.
Returns
0 or greater on success (the log id) or a negative error code on failure.

◆ close()

Sint32 CRM64Pro::LogMgr::close ( Sint32 idLog)

Close and destroy a log object.

Parameters
idLog0 to close all logs, or a specific log id. The default log cannot be removed with this method.
Returns
0 on success, or a negative error code on failure.
Note
The default log (id=0) is ignored and will not be closed.

◆ getNum()

Sint32 CRM64Pro::LogMgr::getNum ( ) const

Get number of loaded objects.

Returns
Number of log objects.

◆ setName()

Sint32 CRM64Pro::LogMgr::setName ( Sint32 idLog,
const string & sName )

Change the object name.

Parameters
idLogLog id.
sNamenew name (e.g. 'myLog'). Must be unique; longer names are truncated to 64 characters.
Returns
0 on success, or a negative error code on failure.

◆ get()

Log * CRM64Pro::LogMgr::get ( Sint32 idLog = 0)

Get a pointer to the log object.

Parameters
idLogLog id. 0 (default) returns the default log.
Returns
nullptr if the log was not found, otherwise a pointer to the Log object.