Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
composer.phar
vendor/
.idea/
32 changes: 31 additions & 1 deletion lib/LogManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

use Doctrine\Common\Collections\ArrayCollection;
use Syonix\LogViewer\Exceptions\NoLogsConfiguredException;
use League\Flysystem\Filesystem;
use League\Flysystem\Adapter\Local;

/**
* Represents the entry point for the application.
Expand All @@ -22,12 +24,40 @@ public function __construct($logs)
if (count($logs) == 0) {
throw new NoLogsConfiguredException();
}

foreach ($logs as $logCollectionName => $logCollectionLogs) {

if (count($logCollectionLogs) > 0) {

$logCollection = new LogCollection($logCollectionName);

foreach ($logCollectionLogs as $logName => $args) {
$logCollection->addLog(new LogFile($logName, $logCollection->getSlug(), $args));

if ( isset( $args['is_dir'] ) && $args['is_dir']) {

$collection_path = $args['path'];
$log_adapter = new Local($args['path']);
$filesystem = new Filesystem($log_adapter);

foreach ($filesystem->listContents() as $log_file) {

if($log_file['type'] != 'file') {
continue;
}

$args = ['type' => 'local', 'path' => $collection_path . $log_file['path']];
$logCollection->addLog(new LogFile($log_file['filename'], $log_file['filename'], $args));

}

} else {

$logCollection->addLog(new LogFile($logName, $logCollection->getSlug(), $args));

}

}

$this->logCollections->add($logCollection);
}
}
Expand Down