Skip to content

Commit

Permalink
Merge pull request #170 from fupa/DV-15754-disable-verbose-job-logging
Browse files Browse the repository at this point in the history
make verbose job logging configurable but disable it by default
  • Loading branch information
mnapoli authored Feb 12, 2025
2 parents 50afe06 + b25c7f1 commit e644c76
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 7 deletions.
10 changes: 10 additions & 0 deletions config/bref.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,14 @@

'request_context' => false,

/*
|--------------------------------------------------------------------------
| Jobs Logging
|--------------------------------------------------------------------------
|
| Here you can disable detailed logging of every job execution.
|
*/

'log_jobs' => true,
];
24 changes: 17 additions & 7 deletions src/BrefServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,23 @@ public function boot(Dispatcher $dispatcher, LogManager $logManager, FailedJobPr
], 'bref-config');
}

if (config('bref.log_jobs', true)) {
$this->enableDetailedJobLogging($dispatcher, $logManager, $queueFailer);
}

if (file_exists('/proc/1/fd/1')) {
$dispatcher->listen(
ScheduledTaskStarting::class,
fn(ScheduledTaskStarting $task) => $task->task->appendOutputTo('/proc/1/fd/1'),
);
}
}

private function enableDetailedJobLogging(
Dispatcher $dispatcher,
LogManager $logManager,
FailedJobProviderInterface $queueFailer
): void {
$dispatcher->listen(
fn (JobProcessing $event) => $logManager->info(
"Processing job {$event->job->getJobId()}",
Expand Down Expand Up @@ -102,13 +119,6 @@ public function boot(Dispatcher $dispatcher, LogManager $logManager, FailedJobPr
$event->exception
)
);

if (file_exists('/proc/1/fd/1')) {
$dispatcher->listen(
ScheduledTaskStarting::class,
fn(ScheduledTaskStarting $task) => $task->task->appendOutputTo('/proc/1/fd/1'),
);
}
}

/**
Expand Down

0 comments on commit e644c76

Please sign in to comment.