Guides

BricksMembers Documentation

Find everything you need to set up, customize, and get the most out of BricksMembers — from quick-start guides to advanced features.

Debug Logging & Development Tools

Debug Logging & Development Tools
Pascal Basel
modified at December 8, 2025

BricksMembers includes debug logging functions to help you troubleshoot issues and understand plugin behavior during development.

Enable Debug Mode

Enable debug logging in your wp-config.php:

// Enable BricksMembers logging
define( 'BRM_DEBUG', true );
define( 'BRM_DEBUG_LEVEL', 'debug' ); // Options: debug, info, warning, error

If BRM_DEBUG is not defined, the plugin falls back to WordPress debug settings (WP_DEBUG and WP_DEBUG_LOG).

Which to use? Use BRM_DEBUG to enable logging. By default the logger records all levels (debug/info/warning/error); set BRM_DEBUG_LEVEL to raise the threshold.

What Gets Logged

Logging calls already exist across the plugin and will emit when debug mode is on. Examples include:

  • Security/auth: webhook auth failures/rate limits, AJAX nonce/capability failures, API key verification
  • Core flows: access denials, level assignments, recompute scheduling, batch worker start/finish (SPM, Progress, Drip)
  • Data mutations: level create/update/delete failures, progress toggle failures (already-completed/not-tracked)
  • Modules: protected downloads activity, licensing checks, rate-limiting events

Logging Functions

Use these functions to log messages at different levels:

// Debug messages (detailed information)
brm_log_debug( 'User levels retrieved', [
    'user_id' => 123,
    'levels' => [1, 2, 5]
] );

// Info messages (general information)
brm_log_info( 'Structure recompute started', [
    'structure_id' => 'courses'
] );

// Warning messages (potential issues)
brm_log_warning( 'Slow query detected', [
    'query_time' => 1.5
] );

// Error messages (failures)
brm_log_error( 'Failed to assign level', [
    'user_id' => 123,
    'level_id' => 5
] );

Exception Logging

Log exceptions with full context:

try {
    $result = brm_core()->add_user_level( $user_id, $level_id );
} catch ( Exception $e ) {
    brm_log_exception( $e, [
        'user_id' => $user_id,
        'level_id' => $level_id,
        'operation' => 'add_user_level'
    ] );
}

Performance Logging

Track operation performance:

$start_time = microtime( true );

// Perform operation
$result = brm_schedule_unified_recompute( [
    'structures' => [ $structure_id ],
    'spm' => true
] );

$duration = microtime( true ) - $start_time;

brm_log_performance( 'unified_recompute', $duration, [
    'structure_id' => $structure_id,
    'result' => $result
] );

Log Output

Logs are written to WordPress debug log (usually wp-content/debug.log) with structured information:

Using Logs in Your Code

Add logging to your custom code that extends BricksMembers:

Best Practices

  • Use appropriate log levels: Use debug for detailed info, error for failures
  • Include context: Always pass relevant data as the second parameter
  • Don’t log sensitive data: Never log passwords, API keys, or personal information
  • Disable in production: Only enable BRM_DEBUG during development
  • Review logs regularly: Check logs to identify performance issues or errors

Create

Start Building with BricksMembers

Create, sell, and manage your content without limits. BricksMembers gives you everything you need to build membership and LMS sites directly in Bricks Builder — fast and frustration-free.

Join the membership & LMS revolution now!

Get Started
Still have questions? We're here to help!