Filter: wpd_ai_starshipit_enable_logging

Control whether logging is enabled for the StarShipIt integration. This allows you to enable or disable debug logging for shipping integration operations.

Description

The StarShipIt integration can log API requests, responses, and errors for debugging purposes. This filter allows you to control whether this logging is enabled, which is useful for troubleshooting shipping integration issues or disabling logs in production.

Location

File: includes/integrations/pro/WPDAI_StarShipIt.php

Method: WPDAI_StarShipIt::__construct()

Line: ~50

Parameters

Parameter Type Description
$enable_logging bool Whether logging is enabled (default: false)

Return

Type: bool

Description: True to enable logging, false to disable

Example Usage

Enable Logging in Development

add_filter( 'wpd_ai_starshipit_enable_logging', 'enable_starshipit_logging_dev' );
function enable_starshipit_logging_dev( $enable_logging ) {
    // Enable logging in development environment
    if ( defined( 'WP_ENVIRONMENT_TYPE' ) && WP_ENVIRONMENT_TYPE === 'development' ) {
        return true;
    }
    return $enable_logging;
}

Enable Logging When Debug Mode is On

add_filter( 'wpd_ai_starshipit_enable_logging', 'enable_starshipit_logging_debug' );
function enable_starshipit_logging_debug( $enable_logging ) {
    // Enable logging when WP_DEBUG is enabled
    if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
        return true;
    }
    return $enable_logging;
}

Enable Logging for Specific Users

add_filter( 'wpd_ai_starshipit_enable_logging', 'enable_starshipit_logging_for_admins' );
function enable_starshipit_logging_for_admins( $enable_logging ) {
    // Enable logging for administrators
    if ( current_user_can( 'manage_options' ) ) {
        return true;
    }
    return $enable_logging;
}

Always Enable Logging

add_filter( 'wpd_ai_starshipit_enable_logging', '__return_true' );

Conditional Logging Based on Error Rate

add_filter( 'wpd_ai_starshipit_enable_logging', 'enable_logging_on_errors' );
function enable_logging_on_errors( $enable_logging ) {
    // Check recent error rate
    $recent_errors = get_transient( 'WPDAI_StarShipIt_error_count' );
    
    // Enable logging if we've had errors recently
    if ( $recent_errors && $recent_errors > 5 ) {
        return true;
    }
    
    return $enable_logging;
}

Best Practices

What Gets Logged

When logging is enabled, the StarShipIt integration logs:

Important Notes

Finding Log Files

Logs are typically written to: