Skip to content

Commit

Permalink
remove logger. check scheduledTaskMonitoringEnabled
Browse files Browse the repository at this point in the history
  • Loading branch information
aozisik committed Dec 19, 2023
1 parent 47e8c98 commit 8224aac
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 20 deletions.
27 changes: 17 additions & 10 deletions src/AppkeepProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,23 +80,30 @@ public function bootForConsole()

protected function watchScheduledTasks(Schedule $schedule)
{
/**
* @var AppkeepService
*/
$appkeep = app('appkeep');

if (!$appkeep->scheduledTaskMonitoringEnabled) {
return;
}

collect($schedule->events())
->filter(function ($event) {
logger($event->command);
// Don't monitor the Appkeep scheduled task itself.
return $event->command && ! str_contains($event->command, 'appkeep:run');
return $event->command && !str_contains($event->command, 'appkeep:run');
})
->each(function (Event $event) {
/**
* @var AppkeepService
*/
$appkeep = app('appkeep');

->each(function (Event $event) use ($appkeep) {
$event->before(fn () => $appkeep->scheduledTaskStarted($event));

$event->onSuccessWithOutput(fn () => $appkeep->scheduledTaskCompleted($event));
$event->onSuccessWithOutput(
fn () => $appkeep->scheduledTaskCompleted($event)
);

$event->onFailureWithOutput(fn () => $appkeep->scheduledTaskFailed($event));
$event->onFailureWithOutput(
fn () => $appkeep->scheduledTaskFailed($event)
);
});
}
}
10 changes: 0 additions & 10 deletions src/Concerns/ReportsScheduledTaskOutputs.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,6 @@ private function getScheduledTaskRunDuration(): int

public function scheduledTaskFailed(Event $task)
{
if (! app('appkeep')->scheduledTaskMonitoringEnabled) {
// If monitoring is disabled, don't send the output
return;
}

$duration = $this->getScheduledTaskRunDuration();
$finishedAt = now();

Expand All @@ -61,11 +56,6 @@ public function scheduledTaskFailed(Event $task)

public function scheduledTaskCompleted(Event $task)
{
if (! app('appkeep')->scheduledTaskMonitoringEnabled) {
// If monitoring is disabled, don't send the output
return;
}

$duration = $this->getScheduledTaskRunDuration();
$finishedAt = now();

Expand Down

0 comments on commit 8224aac

Please sign in to comment.