Wpd Ai Starshipit Enable Logging

Alpha Insights Documentation

Docs Navigation

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/WPD_StarShipIt.php

Method: WPD_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( 'wpd_starshipit_error_count' );
    
    // Enable logging if we've had errors recently
    if ( $recent_errors && $recent_errors > 5 ) {
        return true;
    }
    
    return $enable_logging;
}

Best Practices

  • Keep logging disabled in production for performance
  • Enable logging only when troubleshooting issues
  • Use conditional logic based on environment or user role
  • Monitor log file size if logging is enabled
  • Disable logging after resolving issues
  • Logs can help diagnose API integration problems

What Gets Logged

When logging is enabled, the StarShipIt integration logs:

  • API request URLs and parameters
  • API response data
  • Error messages and exceptions
  • Authentication attempts
  • Shipping label generation attempts
  • Rate calculation requests

Important Notes

  • Default is false – logging is disabled by default
  • Logging can generate large log files over time
  • Enable logging only when needed for debugging
  • Logs may contain sensitive API information
  • This only affects StarShipIt integration logging
  • Check your WordPress debug log location for log files

Finding Log Files

Logs are typically written to:

  • WordPress debug log (if WP_DEBUG_LOG is enabled)
  • Location defined by WP_DEBUG_LOG constant
  • Default: wp-content/debug.log
  • To check your log location:

if ( defined( 'WP_DEBUG_LOG' ) ) {
    error_log( 'Debug log location: ' . WP_DEBUG_LOG );
}

When to Enable Logging

Enable logging when:

  • Troubleshooting StarShipIt integration issues
  • API requests are failing
  • Shipping labels aren’t generating
  • Rate calculations are incorrect
  • In development or staging environments

Keep logging disabled when:

  • Integration is working correctly
  • In production environments
  • Performance is a concern
  • Log files are growing too large

Related Classes

  • WPD_StarShipIt – StarShipIt shipping integration

Debugging

add_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

Got A Question?

Subscribe
Notify of
guest
0 Comments
Newest
Oldest Most Voted
Inline Feedbacks
View all comments
Alpha Insights

Alpha Insights

The World's Most Advanced WooCommerce Drag & Drop Report Builder.

5/5 – Trustpilot

Alpha Insights