Skip to content

Commit

Permalink
Fixed error because of log file not exist when running tail:db command.
Browse files Browse the repository at this point in the history
  • Loading branch information
muhdfaiz committed Nov 25, 2020
1 parent 3f69afd commit e3120b1
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/TailDatabaseCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,14 @@ public function __construct()
*/
public function handle()
{
$filename = config('tail-db.filename');
$path = config('tail-db.path');

// Check file exist. If not exist create empty log file.
if (!file_exists( $path . '/' . $filename)) {
file_put_contents($path . '/' . $filename, '');
}

// Show an error message if Laravel Tail DB not enabled.
if (!$this->checkStatusEnabled()) {
$this->output->writeln(PHP_EOL);
Expand All @@ -57,6 +65,10 @@ public function handle()
->setTty(false)
->setTimeout(null)
->run(function ($type, $logData) {
if (!$logData) {
return;
}

$logData = $this->parseLogData($logData);

$this->outputQueryDetails($logData);
Expand Down

0 comments on commit e3120b1

Please sign in to comment.