This is required when setting logging channels in the logging.php config file anyways.
Showing 2 of 4 files from the diff.
src/Commands/LogCleanerUpper.php
changed.
src/LogToDB.php
changed.
Other files ignored by Codecov
phpunit.xml
has changed.
readme.md
has changed.
@@ -49,24 +49,22 @@
Loading
49 | 49 | $channels = $this->getLogToDbChannels(); |
|
50 | 50 | ||
51 | 51 | if (!empty($channels)) { |
|
52 | - | foreach ($channels as $channel) { |
|
52 | + | foreach ($channels as $name => $channel) { |
|
53 | 53 | $maxRecords = $channel['max_records'] ?? $config['purge_log_when_max_records'] ?? false; |
|
54 | 54 | $maxHours = $channel['max_hours'] ?? $config['purge_log_when_max_records'] ?? false; |
|
55 | - | $connection = $channel['connection'] ?? 'default'; |
|
56 | - | $collection = $channel['collection'] ?? 'log'; |
|
57 | 55 | ||
58 | 56 | //delete based on numbers of records |
|
59 | 57 | if (!empty($maxRecords) && $maxRecords > 0) { |
|
60 | - | if (LogToDB::model($connection, $collection)->removeOldestIfMoreThan($maxRecords)) { |
|
61 | - | $this->warn("Deleted oldest log records on channel: {$connection}->{$collection}, keep max number of records: {$maxRecords}"); |
|
58 | + | if (LogToDB::model($name)->removeOldestIfMoreThan($maxRecords)) { |
|
59 | + | $this->warn("Deleted oldest records on log channel: {$name}, keep max number of records: {$maxRecords}"); |
|
62 | 60 | } |
|
63 | 61 | } |
|
64 | 62 | ||
65 | 63 | //delete based on age |
|
66 | 64 | if (!empty($maxHours) && $maxHours > 0) { |
|
67 | 65 | $time = Carbon::now()->subHours($maxHours)->toDateTimeString(); |
|
68 | - | if (LogToDB::model($connection, $collection)->removeOlderThan($time)) { |
|
69 | - | $this->warn("Deleted log records on channel: {$connection}->{$collection}, older than: {$time}"); |
|
66 | + | if (LogToDB::model($name)->removeOlderThan($time)) { |
|
67 | + | $this->warn("Deleted oldest records on log channel: {$name}, older than: {$time}"); |
|
70 | 68 | } |
|
71 | 69 | } |
|
72 | 70 | } |
@@ -81,9 +79,10 @@
Loading
81 | 79 | $list = []; |
|
82 | 80 | $logging = config('logging'); |
|
83 | 81 | if (!empty($logging) && isset($logging['channels']) && !empty($logging['channels'])) { |
|
84 | - | foreach ($logging['channels'] as $log) { |
|
85 | - | if (isset($log['via']) && $log['via'] === LogToDbHandler::class) { |
|
86 | - | $list[] = $log; |
|
82 | + | foreach ($logging['channels'] as $name => $channel) { |
|
83 | + | //Only look for the relevant logging class in the config. |
|
84 | + | if (isset($channel['via']) && $channel['via'] === LogToDbHandler::class) { |
|
85 | + | $list[$name] = $channel; |
|
87 | 86 | } |
|
88 | 87 | } |
|
89 | 88 | } |
@@ -80,6 +80,9 @@
Loading
80 | 80 | /** |
|
81 | 81 | * Return a new LogToDB Module instance. |
|
82 | 82 | * |
|
83 | + | * If specifying 'channel, 'connection' and 'collection' would not be needed (they will be extracted from channel). |
|
84 | + | * If specifying 'connection' and 'collection', 'channel' is not needed. |
|
85 | + | * |
|
83 | 86 | * @param string|null $channel |
|
84 | 87 | * @param string|null $connection |
|
85 | 88 | * @param string|null $collection |
Files | Complexity | Coverage |
---|---|---|
src | 116 | 96.90% |
Project Totals (13 files) | 116 | 96.90% |
88.2
7.3=.3 TRAVIS_OS_NAME=linux
87.2
7.3=.3 TRAVIS_OS_NAME=linux
89.2
7.3=.3 TRAVIS_OS_NAME=linux
Sunburst
The inner-most circle is the entire project, moving away from the center are folders then, finally, a single file.
The size and color of each slice is representing the number of statements and the coverage, respectively.
Icicle
The top section represents the entire project. Proceeding with folders and finally individual files.
The size and color of each slice is representing the number of statements and the coverage, respectively.