Filter
uncanny-automator
automator_prune_logs_minimum_input
Filters the minimum number of logs to consider for pruning, allowing customization of when log cleanup occurs.
add_filter( 'automator_prune_logs_minimum_input', $callback, 10, 1 );
Description
Allows developers to filter the minimum input value used for pruning logs. This filter fires during the initialization of the `PruneLogs` class, before any pruning actions are taken. Developers can modify this value to change the threshold for what is considered "minimum input" for log pruning.
Usage
add_filter( 'automator_prune_logs_minimum_input', 'your_function_name', 10, 1 );
Parameters
-
$this(mixed) - This parameter specifies the minimum number of log entries required before the pruning process can be initiated.
Return Value
The filtered value.
Examples
/**
* Filter to adjust the minimum input required for log pruning.
*
* This example increases the minimum input required for pruning logs to 10MB
* if the default value is less than that. This could be useful for sites
* with very large log files where you want to ensure a significant amount
* of data is eligible for pruning to avoid frequent, low-impact operations.
*
* @param int $minimum_input The current minimum input size in bytes.
* @return int The potentially adjusted minimum input size in bytes.
*/
add_filter( 'automator_prune_logs_minimum_input', function( $minimum_input ) {
$target_minimum_bytes = 10 * 1024 * 1024; // 10MB
// Only increase the minimum if the current value is smaller
if ( $minimum_input < $target_minimum_bytes ) {
return $target_minimum_bytes;
}
return $minimum_input;
}, 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/core/admin/class-prune-logs.php:50
public function __construct( $should_register_hooks = true ) {
if ( $should_register_hooks ) {
$this->register_hooks();
}
$this->minimum_input = apply_filters( 'automator_prune_logs_minimum_input', $this->minimum_input );
// Calculate table size. This hook needs to be registered unconditionally.
add_action( self::$cron_schedule, array( $this, 'calculate_and_save_table_size' ) );
// Update failed recipes. This hook also needs to be registered unconditionally.
add_action( 'automator_daily_healthcheck', array( $this, 'update_failed_recipes' ) );
}