Skip to content

Commit 456848f

Browse files
author
Xavier Barbosa
committed
Better handling when there are no storage files, code clean up.
1 parent 424176c commit 456848f

File tree

1 file changed

+18
-7
lines changed

1 file changed

+18
-7
lines changed

src/Console/Debug.php

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class Debug extends Command
2020
*
2121
* @var string
2222
*/
23-
protected $description = 'Collects query data and stats.';
23+
protected $description = 'Displays laravel debug bar stored information.';
2424

2525
/**
2626
* Execute the console command.
@@ -37,35 +37,35 @@ public function handle()
3737
try {
3838
$latestFile = $debug->getStorage()->find([], 1);
3939
} catch (InvalidArgumentException $exception) {
40+
$this->refresh();
4041
$this->error($exception->getMessage());
4142

42-
return;
43+
continue;
4344
}
4445

4546
$id = array_get($latestFile, '0.id');
4647

4748
// No file found so continue
4849
if (empty($id)) {
49-
sleep(1);
50+
$this->refresh();
51+
$this->warn('No laravel debugbar stored files available. Do a request and make sure APP_DEBUG is set to true.');
5052

5153
continue;
5254
}
5355

5456
// Latest file is the same do not render
5557
if (array_get($profileData, '__meta.id') === $id) {
56-
sleep(1);
58+
$this->wait();
5759

5860
continue;
5961
}
6062

6163
$profileData = $debug->getStorage()->get($id);
6264

63-
system('clear');
65+
$this->refresh();
6466
$this->info('Latest Request Information:');
6567
$this->renderMetaData($profileData);
6668
$this->renderQueryData($profileData);
67-
68-
sleep(1);
6969
}
7070
}
7171

@@ -87,6 +87,17 @@ public function renderMetaData(array $data)
8787
]);
8888
}
8989

90+
public function wait()
91+
{
92+
sleep(1);
93+
}
94+
95+
public function refresh()
96+
{
97+
$this->wait();
98+
system('clear');
99+
}
100+
90101
/**
91102
* @param array $data
92103
*/

0 commit comments

Comments
 (0)