No flags found
Use flags to group coverage reports by test type, project and/or folders.
Then setup custom commit statuses and notifications for each flag.
e.g., #unittest #integration
#production #enterprise
#frontend #backend
0e8ad2a
... +0 ...
e4def4b
Use flags to group coverage reports by test type, project and/or folders.
Then setup custom commit statuses and notifications for each flag.
e.g., #unittest #integration
#production #enterprise
#frontend #backend
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 | 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 | 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 |
Learn more Showing 6 files with coverage changes found.
src/migrations/2018_08_11_003343_create_log_table.php
src/LogToDbHandler.php
src/Models/DBLog.php
src/Models/DBLogMongoDB.php
src/ServiceProvider.php
src/Jobs/SaveNewLogEvent.php
Files | Complexity | Coverage |
---|---|---|
src | ø | 0.05% 96.90% |
Project Totals (13 files) | 116 | 96.90% |
e4def4b
0e8ad2a