I have 2 log files which i read and get the contents as array. The array which i get is like this:
2 => array:9 [▼
"app" => "a.log"
"context" => "local"
"level" => "error"
"level_class" => "danger"
"level_img" => "exclamation-triangle"
"date" => "2018-10-25 21:01:04"
"text" => "Class 'Arcanedev\Support\Collection' not found
]
3 => array:9 [▼
"app" => "b.log"
"context" => "local"
"level" => "error"
"level_class" => "danger"
"level_img" => "exclamation-triangle"
"date" => "2018-10-26 16:49:07"
I need to get the count of all the error levels for each file. For example:
a.log => "count of error level for a.log",
b.log => "count of error levels for b.log"
I have tried:
foreach($names as $filename){
$logs = $this->getLogs($this->filepath.$filename);
$result = array();
$result[ $filename ] = $logs;
foreach($logs as $log){
//$result[ $log['level'] ][] = $log;
$result[ $filename ][] = $log;
$counts = array_map('count', $result);
}
}
which gives me this result:
array:1 [▼
"laravel.log" => 20
]
Any help is appreciated. Thank you in advance. :)
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire