Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/6.x' into 6.x
Browse files Browse the repository at this point in the history
  • Loading branch information
AugustMiller committed Aug 14, 2024
2 parents bf3987f + 23a2be0 commit 032bc51
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 10 deletions.
18 changes: 15 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,26 @@
# 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))
- Fixed a bug that could occur when importing into a Dropdown field that did not support empty strings as a value and the feed had an empty string. ([#1484](https://github.com/craftcms/feed-me/pull/1484))

## 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))
Expand Down Expand Up @@ -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.
- Added support for importing into Icon fields.
26 changes: 23 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
<?php
return [
// disable default logging to database
'logging' => false,
];
```

### config/app.php

```php
<?php
return [
'components' => [
'log' => [
Expand All @@ -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,
],
],
],
Expand Down
17 changes: 17 additions & 0 deletions src/console/controllers/LogsController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

namespace craft\feedme\console\controllers;

use craft\console\Controller;
use craft\feedme\Plugin;
use yii\console\ExitCode;

class LogsController extends Controller
{
public function actionClear(): int
{
Plugin::$plugin->getLogs()->clear();

return ExitCode::OK;
}
}
3 changes: 0 additions & 3 deletions src/controllers/LogsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
6 changes: 5 additions & 1 deletion src/services/Logs.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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)]);
Expand Down

0 comments on commit 032bc51

Please sign in to comment.