From 92606900e280feacef7253cb451eb1254d4b11ac Mon Sep 17 00:00:00 2001 From: Beno!t POLASZEK Date: Tue, 5 Dec 2023 10:27:11 +0100 Subject: [PATCH] feat: update LoggerRecipe with nb loaded items since last flush --- src/Recipe/LoggerRecipe.php | 4 ++-- tests/Unit/Recipe/LoggerRecipeTest.php | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Recipe/LoggerRecipe.php b/src/Recipe/LoggerRecipe.php index 5d33319..127ac0c 100644 --- a/src/Recipe/LoggerRecipe.php +++ b/src/Recipe/LoggerRecipe.php @@ -127,9 +127,9 @@ public function decorate(EtlExecutor $executor): EtlExecutor ->onFlush( fn (FlushEvent $event) => $this->log( $event, - $event->early ? 'Flushing items (early)...' : 'Flushing items...', + $event->early ? 'Flushing {nb} items (early)...' : 'Flushing {nb} items...', [ - 'key' => $event->state->currentItemKey, + 'nb' => $event->state->nbLoadedItemsSinceLastFlush, 'state' => $event->state, ], ), diff --git a/tests/Unit/Recipe/LoggerRecipeTest.php b/tests/Unit/Recipe/LoggerRecipeTest.php index 237ddae..843098a 100644 --- a/tests/Unit/Recipe/LoggerRecipeTest.php +++ b/tests/Unit/Recipe/LoggerRecipeTest.php @@ -30,12 +30,12 @@ fn ($record) => $record->message->toContain('Extracting item')->and($record->level->toBe(Level::Debug)), fn ($record) => $record->message->toContain('Transformed item')->and($record->level->toBe(Level::Debug)), fn ($record) => $record->message->toContain('Loaded item')->and($record->level->toBe(Level::Debug)), - fn ($record) => $record->message->toContain('Flushing items (early)...')->and($record->level->toBe(Level::Info)), + fn ($record) => $record->message->toContain('Flushing {nb} items (early)...')->and($record->level->toBe(Level::Info)), fn ($record) => $record->message->toContain('Extracting item')->and($record->level->toBe(Level::Debug)), fn ($record) => $record->message->toContain('Transformed item')->and($record->level->toBe(Level::Debug)), fn ($record) => $record->message->toContain('Loaded item')->and($record->level->toBe(Level::Debug)), - fn ($record) => $record->message->toContain('Flushing items (early)...')->and($record->level->toBe(Level::Info)), - fn ($record) => $record->message->toContain('Flushing items...')->and($record->level->toBe(Level::Info)), + fn ($record) => $record->message->toContain('Flushing {nb} items (early)...')->and($record->level->toBe(Level::Info)), + fn ($record) => $record->message->toContain('Flushing {nb} items...')->and($record->level->toBe(Level::Info)), fn ($record) => $record->message->toContain('ETL complete.')->and($record->level->toBe(Level::Info)), ); });