Filter uncanny-automator

automator_logs_extension

Filters log entries for automator, allowing modification of the 'log' parameter before it is saved or displayed.

add_filter( 'automator_logs_extension', $callback, 10, 1 );

Description

Fires when the log file extension is being defined. Developers can use this filter to dynamically change the file extension used for automator logs, for example, to '.txt' or '.log'. The default is 'log'.


Usage

add_filter( 'automator_logs_extension', 'your_function_name', 10, 1 );

Return Value

The filtered value.


Examples

/**
 * Filters the log extension to potentially add a custom suffix for development purposes.
 *
 * For example, during development, you might want to differentiate logs
 * from different environments by appending a suffix.
 *
 * @param mixed $log_extension The current log extension value.
 * @return string The modified log extension.
 */
add_filter( 'automator_logs_extension', function( $log_extension ) {
    // Check if a specific constant is defined to enable development logging.
    // This is a hypothetical constant, you'd define it elsewhere if needed.
    if ( defined( 'AUTOMATOR_DEV_MODE' ) && AUTOMATOR_DEV_MODE ) {
        // Append a development suffix to the log extension.
        return $log_extension . '_dev';
    }

    // Otherwise, return the original log extension.
    return $log_extension;
}, 10, 1 );

Placement

This code should be placed in the functions.php file of your active theme, a custom plugin, or using a code snippets plugin.


Source Code

src/globals.php:51

}

if ( ! defined( 'AUTOMATOR_API_URL' ) ) {
	define( 'AUTOMATOR_API_URL', apply_filters( 'automator_api_url', 'https://api.automatorplugin.com/' ) );
}

if ( ! defined( 'AUTOMATOR_LOGS_EXT' ) ) {
	define( 'AUTOMATOR_LOGS_EXT', apply_filters( 'automator_logs_extension', 'log' ) );
}

if ( ! defined( 'AUTOMATOR_SITE_KEY' ) ) {
	define( 'AUTOMATOR_SITE_KEY', Utilities::get_key() );
}


Scroll to Top