Commit c5e9ca5a authored by Dominik Hebeler's avatar Dominik Hebeler
Browse files

fixed log creation

parent a015ac4e
......@@ -54,17 +54,19 @@ class AppendLogs extends Command
}
$elements = [];
$elementCount = $redis->llen(\App\Console\Commands\AppendLogs::LOGKEY);
$elements = $redis->lpop(\App\Console\Commands\AppendLogs::LOGKEY, $elementCount);
if (!is_array($elements) || sizeof($elements) <= 0) {
return;
while(($value = $redis->lpop(\App\Console\Commands\AppendLogs::LOGKEY)) !== false){
$elements[] = $value;
}
if (file_put_contents(\App\MetaGer::getMGLogFile(), implode(PHP_EOL, $elements) . PHP_EOL, FILE_APPEND) === false) {
$this->error("Konnte Log Zeile(n) nicht schreiben");
$redis->lpush(\App\Console\Commands\AppendLogs::LOGKEY, array_reverse($elements));
} else {
$this->info("Added " . sizeof($elements) . " lines to todays log!");
$this->error("Konnte " . sizeof($elements) . " Log Zeile(n) nicht schreiben");
foreach($elements as $element){
$redis->lPush(\App\Console\Commands\AppendLogs::LOGKEY, $element);
}
}else{
$this->info("Added " . sizeof($elements) . " lines to todays log! " . \App\MetaGer::getMGLogFile());
}
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment