CX Framework
Cross-platform C utility framework
Loading...
Searching...
No Matches
Debug Log Buffer

Macros

#define DBGLOG_SIZE   65535
 Size of the debug log buffer in bytes (64KB)
 

Functions

void dbgLogEnable (int level)
 
void dbgLogDisable ()
 

Variables

char * dbgLog
 

Detailed Description

Circular memory buffer that captures recent log messages for crash dump analysis.

The debug log is a fixed 64KB circular buffer registered as a log destination that automatically includes itself in crash dumps. This allows crash analyzers to see the last ~64KB of log output leading up to a crash, providing critical context for debugging.

Key features:

Typical workflow:

// Enable debug logging at startup
// Normal logging calls automatically go to debug buffer
logInfo(_S"Application started");
logDebug(_S"Loading configuration");
// On crash, the buffer contents are included in crash dumps
// Disable when no longer needed (rare)
void dbgLogDisable()
void dbgLogEnable(int level)
@ LOG_Verbose
Detailed informational messages.
Definition log.h:62
#define _S
Creates a static ASCII string from a string literal.
Definition strbase.h:392

The buffer uses the compact log format from Memory Buffer Logging and is visible to both debuggers (via dbgLog pointer) and crash dump tools.

Function Documentation

◆ dbgLogDisable()

void dbgLogDisable ( )

Disable debug log buffer and unregister from logging system

Unregisters the debug log destination, removes the buffer from crash dumps, and frees the buffer memory. Sets dbgLog to NULL. Safe to call when already disabled (no-op).

◆ dbgLogEnable()

void dbgLogEnable ( int  level)

Enable debug log buffer and register with logging system

Parameters
levelMaximum log level to capture (e.g., LOG_Verbose, LOG_Debug, LOG_Info)

Allocates a 64KB circular buffer, registers it as a log destination, and includes it in crash dumps. If debug logging is already enabled, disables it first before re-enabling with the new level.

All log messages at or below the specified level (from all non-private categories) will be written to the buffer in addition to other destinations.

Variable Documentation

◆ dbgLog

char* dbgLog
extern

Pointer to debug log buffer (NULL when disabled)

Global pointer to the circular log buffer. Visible to debuggers and automatically included in crash dumps when enabled. Points to NULL when debug logging is not active.