Control whether logging is enabled for the StarShipIt integration. This allows you to enable or disable debug logging for shipping integration operations.
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.
File: includes/integrations/pro/WPDAI_StarShipIt.php
Method: WPDAI_StarShipIt::__construct()
Line: ~50
| Parameter | Type | Description |
|---|---|---|
| $enable_logging | bool | Whether logging is enabled (default: false) |
Type: bool
Description: True to enable logging, false to disable
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;
}
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;
}
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;
}
add_filter( 'wpd_ai_starshipit_enable_logging', '__return_true' );
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;
}
When logging is enabled, the StarShipIt integration logs:
Logs are typically written to:
WP_DEBUG_LOG is enabled)WP_DEBUG_LOG constantwp-content/debug.logTo check your log location:
if ( defined( 'WP_DEBUG_LOG' ) ) {
error_log( 'Debug log location: ' . WP_DEBUG_LOG );
}
Enable logging when:
Keep logging disabled when:
WPDAI_StarShipIt - StarShipIt shipping integrationadd_filter( 'wpd_ai_starshipit_enable_logging', 'debug_starshipit_logging', 999 );
function debug_starshipit_logging( $enable_logging ) {
error_log( 'Alpha Insights StarShipIt Logging: ' . ( $enable_logging ? 'ENABLED' : 'DISABLED' ) );
return $enable_logging;
}
To view logs in real-time (Linux/Mac):
tail -f wp-content/debug.log | grep -i starshipit