Skip to content

Commit e3120b1

Browse files
committed
Fixed error because of log file not exist when running tail:db command.
1 parent 3f69afd commit e3120b1

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/TailDatabaseCommand.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,14 @@ public function __construct()
4040
*/
4141
public function handle()
4242
{
43+
$filename = config('tail-db.filename');
44+
$path = config('tail-db.path');
45+
46+
// Check file exist. If not exist create empty log file.
47+
if (!file_exists( $path . '/' . $filename)) {
48+
file_put_contents($path . '/' . $filename, '');
49+
}
50+
4351
// Show an error message if Laravel Tail DB not enabled.
4452
if (!$this->checkStatusEnabled()) {
4553
$this->output->writeln(PHP_EOL);
@@ -57,6 +65,10 @@ public function handle()
5765
->setTty(false)
5866
->setTimeout(null)
5967
->run(function ($type, $logData) {
68+
if (!$logData) {
69+
return;
70+
}
71+
6072
$logData = $this->parseLogData($logData);
6173

6274
$this->outputQueryDetails($logData);

0 commit comments

Comments
 (0)