SW Task Event Loop Framework v1.0.0
High-performance C++ asynchronous event loop framework with timer management and promise-based programming
Loading...
Searching...
No Matches
Debug.h File Reference

Centralized debug and logging macros for SW Task Framework components. More...

#include <iostream>
#include <string>
Include dependency graph for Debug.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define TIMER_DEBUG_ENABLED   0
 Enable/disable debug output for TimerManager operations.
 
#define SLLOOPER_DEBUG_ENABLED   0
 Enable/disable debug output for SLLooper operations.
 
#define EventQueue_DEBUG_ENABLED   0
 Enable/disable debug output for EventQueue operations.
 
#define TIMER_DEBUG(msg)
 Conditional debug logging for TimerManager with simple message.
 
#define TIMER_DEBUG_STREAM(stream_expr)
 Conditional debug logging for TimerManager with stream expression.
 
#define TIMER_ERROR(msg)    std::cout << "[TimerManager ERROR] " << msg << std::endl
 Always-on error logging for TimerManager critical issues.
 
#define TIMER_ERROR_STREAM(stream_expr)    std::cout << "[TimerManager ERROR] " << stream_expr << std::endl
 Always-on error logging for TimerManager with stream expression.
 
#define TIMER_INFO(msg)    std::cout << "[TimerManager] " << msg << std::endl
 Always-on info logging for TimerManager lifecycle events.
 
#define TIMER_INFO_STREAM(stream_expr)    std::cout << "[TimerManager] " << stream_expr << std::endl
 Always-on info logging for TimerManager with stream expression.
 
#define SLLOOPER_DEBUG(msg)
 Conditional debug logging for SLLooper operations.
 
#define SLLOOPER_DEBUG_STREAM(stream_expr)
 Conditional debug logging for SLLooper with stream expression.
 
#define SLLOOPER_ERROR(msg)    std::cout << "[SLLooper ERROR] " << msg << std::endl
 Always-on error logging for SLLooper critical issues.
 
#define SLLOOPER_ERROR_STREAM(stream_expr)    std::cout << "[SLLooper ERROR] " << stream_expr << std::endl
 Always-on error logging for SLLooper with stream expression.
 
#define SLLOOPER_INFO(msg)    std::cout << "[SLLooper] " << msg << std::endl
 Always-on info logging for SLLooper lifecycle events.
 
#define SLLOOPER_INFO_STREAM(stream_expr)    std::cout << "[SLLooper] " << stream_expr << std::endl
 Always-on info logging for SLLooper with stream expression.
 
#define EventQueue_DEBUG(msg)
 Conditional debug logging for EventQueue operations.
 
#define EventQueue_DEBUG_STREAM(stream_expr)
 Conditional debug logging for EventQueue with stream expression.
 
#define EventQueue_ERROR(msg)    std::cout << "[EventQueue ERROR] " << msg << std::endl
 Always-on error logging for EventQueue critical issues.
 
#define EventQueue_ERROR_STREAM(stream_expr)    std::cout << "[EventQueue ERROR] " << stream_expr << std::endl
 Always-on error logging for EventQueue with stream expression.
 
#define EventQueue_INFO(msg)    std::cout << "[EventQueue] " << msg << std::endl
 Always-on info logging for EventQueue lifecycle events.
 
#define EventQueue_INFO_STREAM(stream_expr)
 Always-on info logging for EventQueue with stream expression.
 

Detailed Description

Centralized debug and logging macros for SW Task Framework components.

Author
Tran Anh Tai
Date
9/2025
Version
1.0.0

Definition in file Debug.h.

Macro Definition Documentation

◆ EventQueue_DEBUG

#define EventQueue_DEBUG (   msg)
Value:
do { \
std::cout << "[EventQueue] " << msg << std::endl; \
} \
} while(0)
#define EventQueue_DEBUG_ENABLED
Enable/disable debug output for EventQueue operations.
Definition Debug.h:57

Conditional debug logging for EventQueue operations.

Parameters
msgString literal or expression for debug message

Prints debug message with [EventQueue] prefix only if EventQueue_DEBUG_ENABLED is true. Useful for debugging message queuing and function execution.

EventQueue_DEBUG("Enqueuing function for immediate execution");
#define EventQueue_DEBUG(msg)
Conditional debug logging for EventQueue operations.
Definition Debug.h:281
Note
Can be very high-frequency during active queue processing
Zero runtime cost when EventQueue_DEBUG_ENABLED is 0

Definition at line 281 of file Debug.h.

◆ EventQueue_DEBUG_ENABLED

#define EventQueue_DEBUG_ENABLED   0

Enable/disable debug output for EventQueue operations.

Controls whether debug messages from EventQueue are printed. Default is 0 (disabled) for production builds. Helps debug message queuing, function enqueuing, and polling behavior.

Note
Debug messages include queue operations and timing information
High-frequency operations may generate significant output when enabled

Definition at line 57 of file Debug.h.

◆ EventQueue_DEBUG_STREAM

#define EventQueue_DEBUG_STREAM (   stream_expr)
Value:
do { \
std::cout << "[EventQueue] " << stream_expr << std::endl; \
} \
} while(0)

Conditional debug logging for EventQueue with stream expression.

Parameters
stream_exprStream expression for formatted debug output

Prints debug message using stream operations only if EventQueue_DEBUG_ENABLED is true. Supports detailed queue state and timing information.

EventQueue_DEBUG_STREAM("Queue size: " << size << ", next execution: " << nextTime);
#define EventQueue_DEBUG_STREAM(stream_expr)
Conditional debug logging for EventQueue with stream expression.
Definition Debug.h:300

Definition at line 300 of file Debug.h.

◆ EventQueue_ERROR

#define EventQueue_ERROR (   msg)     std::cout << "[EventQueue ERROR] " << msg << std::endl

Always-on error logging for EventQueue critical issues.

Parameters
msgString literal or expression for error message

Prints error message with [EventQueue ERROR] prefix unconditionally. Used for critical queue operation errors that should always be logged.

EventQueue_ERROR("Failed to enqueue message: out of memory");
#define EventQueue_ERROR(msg)
Always-on error logging for EventQueue critical issues.
Definition Debug.h:319

Definition at line 319 of file Debug.h.

◆ EventQueue_ERROR_STREAM

#define EventQueue_ERROR_STREAM (   stream_expr)     std::cout << "[EventQueue ERROR] " << stream_expr << std::endl

Always-on error logging for EventQueue with stream expression.

Parameters
stream_exprStream expression for formatted error output

Definition at line 327 of file Debug.h.

◆ EventQueue_INFO

#define EventQueue_INFO (   msg)     std::cout << "[EventQueue] " << msg << std::endl

Always-on info logging for EventQueue lifecycle events.

Parameters
msgString literal or expression for info message

Prints informational message with [EventQueue] prefix unconditionally. Used for important queue lifecycle events and significant state changes.

EventQueue_INFO("EventQueue initialized successfully");
#define EventQueue_INFO(msg)
Always-on info logging for EventQueue lifecycle events.
Definition Debug.h:342

Definition at line 342 of file Debug.h.

◆ EventQueue_INFO_STREAM

#define EventQueue_INFO_STREAM (   stream_expr)
Value:
do { \
std::cout << "[EventQueue] " << stream_expr << std::endl; \
} while(0)

Always-on info logging for EventQueue with stream expression.

Parameters
stream_exprStream expression for formatted info output
EventQueue_INFO_STREAM("Queue statistics - processed: " << processed << ", pending: " << pending);
#define EventQueue_INFO_STREAM(stream_expr)
Always-on info logging for EventQueue with stream expression.
Definition Debug.h:354

Definition at line 354 of file Debug.h.

◆ SLLOOPER_DEBUG

#define SLLOOPER_DEBUG (   msg)
Value:
do { \
std::cout << "[SLLooper] " << msg << std::endl; \
} \
} while(0)
#define SLLOOPER_DEBUG_ENABLED
Enable/disable debug output for SLLooper operations.
Definition Debug.h:42

Conditional debug logging for SLLooper operations.

Parameters
msgString literal or expression for debug message

Prints debug message with [SLLooper] prefix only if SLLOOPER_DEBUG_ENABLED is true. Useful for debugging event loop behavior and task execution.

SLLOOPER_DEBUG("Starting event loop thread");
#define SLLOOPER_DEBUG(msg)
Conditional debug logging for SLLooper operations.
Definition Debug.h:191
Note
Zero runtime cost when SLLOOPER_DEBUG_ENABLED is 0
Can be very verbose during active event processing

Definition at line 191 of file Debug.h.

◆ SLLOOPER_DEBUG_ENABLED

#define SLLOOPER_DEBUG_ENABLED   0

Enable/disable debug output for SLLooper operations.

Controls whether debug messages from SLLooper are printed. Default is 0 (disabled) for production builds. Useful for debugging event loop behavior, task posting, and thread coordination.

Note
Debug messages include task posting, loop iterations, and shutdown
Can impact performance when enabled due to I/O operations

Definition at line 42 of file Debug.h.

◆ SLLOOPER_DEBUG_STREAM

#define SLLOOPER_DEBUG_STREAM (   stream_expr)
Value:
do { \
std::cout << "[SLLooper] " << stream_expr << std::endl; \
} \
} while(0)

Conditional debug logging for SLLooper with stream expression.

Parameters
stream_exprStream expression for formatted debug output

Prints debug message using stream operations only if SLLOOPER_DEBUG_ENABLED is true. Allows detailed formatting of debug information.

SLLOOPER_DEBUG_STREAM("Posted task " << taskId << " to queue, size: " << queueSize);
#define SLLOOPER_DEBUG_STREAM(stream_expr)
Conditional debug logging for SLLooper with stream expression.
Definition Debug.h:210

Definition at line 210 of file Debug.h.

◆ SLLOOPER_ERROR

#define SLLOOPER_ERROR (   msg)     std::cout << "[SLLooper ERROR] " << msg << std::endl

Always-on error logging for SLLooper critical issues.

Parameters
msgString literal or expression for error message

Prints error message with [SLLooper ERROR] prefix unconditionally. Used for critical errors in event loop operation that should always be logged (e.g., thread creation failures, queue corruption).

SLLOOPER_ERROR("Failed to start event loop thread");
#define SLLOOPER_ERROR(msg)
Always-on error logging for SLLooper critical issues.
Definition Debug.h:230

Definition at line 230 of file Debug.h.

◆ SLLOOPER_ERROR_STREAM

#define SLLOOPER_ERROR_STREAM (   stream_expr)     std::cout << "[SLLooper ERROR] " << stream_expr << std::endl

Always-on error logging for SLLooper with stream expression.

Parameters
stream_exprStream expression for formatted error output

Definition at line 238 of file Debug.h.

◆ SLLOOPER_INFO

#define SLLOOPER_INFO (   msg)     std::cout << "[SLLooper] " << msg << std::endl

Always-on info logging for SLLooper lifecycle events.

Parameters
msgString literal or expression for info message

Prints informational message with [SLLooper] prefix unconditionally. Used for important event loop lifecycle events and state transitions.

SLLOOPER_INFO("Event loop started successfully");
#define SLLOOPER_INFO(msg)
Always-on info logging for SLLooper lifecycle events.
Definition Debug.h:253

Definition at line 253 of file Debug.h.

◆ SLLOOPER_INFO_STREAM

#define SLLOOPER_INFO_STREAM (   stream_expr)     std::cout << "[SLLooper] " << stream_expr << std::endl

Always-on info logging for SLLooper with stream expression.

Parameters
stream_exprStream expression for formatted info output

Definition at line 261 of file Debug.h.

◆ TIMER_DEBUG

#define TIMER_DEBUG (   msg)
Value:
do { \
std::cout << "[TimerManager] " << msg << std::endl; \
} \
} while(0)
#define TIMER_DEBUG_ENABLED
Enable/disable debug output for TimerManager operations.
Definition Debug.h:27

Conditional debug logging for TimerManager with simple message.

Parameters
msgString literal or expression for debug message

Prints debug message with [TimerManager] prefix only if TIMER_DEBUG_ENABLED is true. Uses do-while(0) idiom for safe macro expansion in all contexts.

TIMER_DEBUG("Creating new timer with 1000ms delay");
#define TIMER_DEBUG(msg)
Conditional debug logging for TimerManager with simple message.
Definition Debug.h:77
Note
Zero runtime cost when TIMER_DEBUG_ENABLED is 0
Thread-safe assuming std::cout is thread-safe

Definition at line 77 of file Debug.h.

◆ TIMER_DEBUG_ENABLED

#define TIMER_DEBUG_ENABLED   0

Enable/disable debug output for TimerManager operations.

Controls whether debug messages from TimerManager are printed. Default is 0 (disabled) for production builds. Can be overridden at compile time with -DTIMER_DEBUG_ENABLED=1.

Note
Debug messages include timer creation, expiration, and cancellation
Production builds should keep this disabled for performance

Definition at line 27 of file Debug.h.

◆ TIMER_DEBUG_STREAM

#define TIMER_DEBUG_STREAM (   stream_expr)
Value:
do { \
std::cout << "[TimerManager] " << stream_expr << std::endl; \
} \
} while(0)

Conditional debug logging for TimerManager with stream expression.

Parameters
stream_exprStream expression (e.g., "Timer " << id << " expired")

Prints debug message using stream operations only if TIMER_DEBUG_ENABLED is true. Allows complex formatted output with variables and expressions.

TIMER_DEBUG_STREAM("Timer " << timerId << " scheduled for " << delay << "ms");
#define TIMER_DEBUG_STREAM(stream_expr)
Conditional debug logging for TimerManager with stream expression.
Definition Debug.h:99
Note
Expressions are only evaluated when debug is enabled
More flexible than TIMER_DEBUG for complex formatting

Definition at line 99 of file Debug.h.

◆ TIMER_ERROR

#define TIMER_ERROR (   msg)     std::cout << "[TimerManager ERROR] " << msg << std::endl

Always-on error logging for TimerManager critical issues.

Parameters
msgString literal or expression for error message

Prints error message with [TimerManager ERROR] prefix unconditionally. Used for critical errors that should always be logged regardless of debug settings (e.g., system call failures, resource allocation errors).

TIMER_ERROR("Failed to create timerfd: " << strerror(errno));
#define TIMER_ERROR(msg)
Always-on error logging for TimerManager critical issues.
Definition Debug.h:122
Note
Always enabled - use sparingly for true error conditions
Consider exception handling instead of just logging

Definition at line 122 of file Debug.h.

◆ TIMER_ERROR_STREAM

#define TIMER_ERROR_STREAM (   stream_expr)     std::cout << "[TimerManager ERROR] " << stream_expr << std::endl

Always-on error logging for TimerManager with stream expression.

Parameters
stream_exprStream expression for formatted error output

Prints error message using stream operations unconditionally. Supports complex formatted error messages with variables and context.

TIMER_ERROR_STREAM("Timer " << id << " failed with errno " << errno);
#define TIMER_ERROR_STREAM(stream_expr)
Always-on error logging for TimerManager with stream expression.
Definition Debug.h:137

Definition at line 137 of file Debug.h.

◆ TIMER_INFO

#define TIMER_INFO (   msg)     std::cout << "[TimerManager] " << msg << std::endl

Always-on info logging for TimerManager lifecycle events.

Parameters
msgString literal or expression for info message

Prints informational message with [TimerManager] prefix unconditionally. Used for important lifecycle events that should be logged in production (e.g., initialization, shutdown, significant state changes).

TIMER_INFO("TimerManager initialized with epoll support");
#define TIMER_INFO(msg)
Always-on info logging for TimerManager lifecycle events.
Definition Debug.h:156
Note
Always enabled - use for important but non-error events
Balance between informativeness and log volume

Definition at line 156 of file Debug.h.

◆ TIMER_INFO_STREAM

#define TIMER_INFO_STREAM (   stream_expr)     std::cout << "[TimerManager] " << stream_expr << std::endl

Always-on info logging for TimerManager with stream expression.

Parameters
stream_exprStream expression for formatted info output

Prints informational message using stream operations unconditionally. Supports formatted output for detailed lifecycle information.

TIMER_INFO_STREAM("Active timers: " << activeCount << ", capacity: " << maxTimers);
#define TIMER_INFO_STREAM(stream_expr)
Always-on info logging for TimerManager with stream expression.
Definition Debug.h:171

Definition at line 171 of file Debug.h.