diff --git a/CHANGELOG.md b/CHANGELOG.md index 418f5414..1be1c2c3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,14 @@ # Release Notes for Feed Me +## 6.3.0 - 2024-08-14 + +- Added a `feed-me/logs/clear` console command to clear database logs. +- Fixed a bug where the logs table would not load with a large number of logs. + +## 6.2.2 - 2024-08-14 + +- Fixed a bug where un-redacted environment variables were being logged to the database. ([#1491](https://github.com/craftcms/feed-me/issues/1491)) + ## 6.2.1 - 2024-07-18 - Fixed a PHP error that could occur when importing Assets that had a missing filename. ([#1481](https://github.com/craftcms/feed-me/pull/1481)) @@ -7,8 +16,11 @@ ## 6.2.0 - 2024-07-09 -> **Warning** -> After updating, you will need to re-map and re-save any feeds that use a Matrix field with a nested complex fields (Google Maps, Table, etc.). +> [!WARNING] +> - After updating, you will need to re-map and re-save any feeds that use a Matrix field with a nested complex fields (Google Maps, Table, etc.). +> - Feed Me now logs to the database by default. +> - This may lead to an increase in database size if logs are not cleared. To customize this behavior, see [Customizing Logs](README.md#customizing-logs). +> - Consider configuring the `logging` setting to `'error'` to reduce logs. - Fixed a bug where complex fields (Google Maps, Table, etc.) would not import correctly when nested inside of a Matrix field. ([#1475](https://github.com/craftcms/feed-me/pull/1475)) - Fixed a PHP error that could occur when importing Entries or Categories with “Default Author” set on the feed mapping. ([#1476](https://github.com/craftcms/feed-me/pull/1476)) @@ -40,4 +52,4 @@ ## 6.0.0 - 2024-03-19 - Feed Me now requires Craft CMS 5.0.0-beta.2 or later. -- Added support for importing into Icon fields. \ No newline at end of file +- Added support for importing into Icon fields. diff --git a/README.md b/README.md index 47e59fd6..0bbd1b21 100644 --- a/README.md +++ b/README.md @@ -34,9 +34,22 @@ composer require craftcms/feed-me ## Customizing Logs As of version `5.6`/`6.2`, logging is handled by Craft's log component and stored in the database instead of the filesystem. -If you want them logged to files (or anywhere else), you can add your own log target in your `config/app.php` file: +To log to files (or anywhere else) instead, you can disable the default logging add your own log target: + +### config/feed-me.php + +```php + false, +]; +``` + +### config/app.php ```php + [ 'log' => [ @@ -48,9 +61,16 @@ return [ // add your own log target to write logs to file 'targets' => [ [ - 'class' => \yii\log\FileTarget::class, - 'logFile' => '@storage/logs/feed-me.log', + // log to file or STDOUT/STDERR if CRAFT_STREAM_LOG=1 is set + 'class' => \craft\log\MonologTarget::class, + 'name' => 'feed-me', 'categories' => ['feed-me'], + + // Don't log request and env vars + 'logContext' => false, + + // Minimum level to log + 'level' => \Psr\Log\LogLevel::INFO, ], ], ], diff --git a/src/console/controllers/LogsController.php b/src/console/controllers/LogsController.php new file mode 100644 index 00000000..2c5ac739 --- /dev/null +++ b/src/console/controllers/LogsController.php @@ -0,0 +1,17 @@ +getLogs()->clear(); + + return ExitCode::OK; + } +} diff --git a/src/controllers/LogsController.php b/src/controllers/LogsController.php index 7603f31c..e9e062d1 100644 --- a/src/controllers/LogsController.php +++ b/src/controllers/LogsController.php @@ -21,9 +21,6 @@ public function actionLogs(): Response $show = Craft::$app->getRequest()->getParam('show'); $logEntries = Plugin::$plugin->getLogs()->getLogEntries($show); - // Limit to 300 for UI - $logEntries = array_slice($logEntries, 0, 300); - return $this->renderTemplate('feed-me/logs/index', [ 'show' => $show, 'logEntries' => $logEntries, diff --git a/src/services/Logs.php b/src/services/Logs.php index dea751d1..e3a741f2 100644 --- a/src/services/Logs.php +++ b/src/services/Logs.php @@ -80,6 +80,7 @@ public function init(): void 'levels' => $this->getLogLevels(), 'enabled' => $this->isEnabled(), 'categories' => [self::LOG_CATEGORY], + 'logVars' => [], 'prefix' => static function(array $message) { $log = Json::decodeIfJson($message[0]); $feed = $log['feed'] ?? null; @@ -134,7 +135,10 @@ public function getLogEntries($type = null): array ->select('*') ->where(['category' => self::LOG_CATEGORY]) ->orderBy(['log_time' => SORT_DESC]) - ->from(self::LOG_TABLE); + ->from(self::LOG_TABLE) + + // Hard-coded until pagination is implemented + ->limit(300); if ($type) { $query->andWhere(['level' => self::logLevelInt($type)]);