Skip to content

Commit e56df3a

Browse files
first go at adding a verbose flag
The idea here is to show what event just started, to help identify long-running events (with bad code we sometimes have crons running for literally hours and it can be tricky to identify the exact event causing the problem).
1 parent 7ece0f6 commit e56df3a

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

src/Cron_Event_Command.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,9 @@ public function schedule( $args, $assoc_args ) {
224224
*
225225
* [--all]
226226
* : Run all hooks.
227+
*
228+
* [--verbose]
229+
* : List event both before and after execution.
227230
*
228231
* ## EXAMPLES
229232
*
@@ -242,7 +245,11 @@ public function run( $args, $assoc_args ) {
242245
}
243246

244247
$executed = 0;
248+
$verbose = Utils\get_flag_value( $assoc_args, 'verbose' );
245249
foreach ( $events as $event ) {
250+
if ( $verbose ) {
251+
WP_CLI::log( sprintf( "Beginning execution of cron event '%s'.", $event->hook ) );
252+
}
246253
$start = microtime( true );
247254
$result = self::run_event( $event );
248255
$total = round( microtime( true ) - $start, 3 );

0 commit comments

Comments
 (0)