Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert to Yii log targets and use DbTarget #1462

Merged
merged 6 commits into from
Jun 12, 2024
Merged
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
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## Unreleased

- Fixed an error that would occur when running a feed with the backup database setting enabled, when Craft's `backupCommand` was set to false. ([#1461](https://github.com/craftcms/feed-me/pull/1461))
- Logs now use the default log component, and are stored in the database. [#1344](https://github.com/craftcms/feed-me/issues/1344)

## 5.5.0 - 2024-05-26

Expand Down Expand Up @@ -159,4 +160,4 @@
- The `data`, `elements`, `feeds`, `fields`, `logs`, `process`, and `service` components can now be configured via `craft\services\Plugins::$pluginConfigs`.

### Removed
- Removed built-in support for the Verbb Comments plugin, which provides its own Feed Me driver.
- Removed built-in support for the Verbb Comments plugin, which provides its own Feed Me driver.
27 changes: 27 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,33 @@ composer require craftcms/feed-me
./craft plugin/install 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:

```php
return [
'components' => [
'log' => [
'monologTargetConfig' => [
// optionally, omit from Craft's default logs
'except' => ['feed-me'],
],

// add your own log target to write logs to file
'targets' => [
[
'class' => \yii\log\FileTarget::class,
'logFile' => '@storage/logs/feed-me.log',
'categories' => ['feed-me'],
],
],
],
],
];
```

## Resources

- **[Feed Me Plugin Page](https://plugins.craftcms.com/feed-me)** – The official plugin page for Feed Me
Expand Down
14 changes: 14 additions & 0 deletions src/migrations/Install.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,24 @@ protected function createTables(): void
'dateUpdated' => $this->dateTime()->notNull(),
'uid' => $this->uid(),
]);

// @see \craft\feedme\migrations\m240611_134740_create_logs_table
$this->createTable('{{%feedme_logs}}', [
'id' => $this->bigPrimaryKey(),
'level' => $this->integer(),
'category' => $this->string(),
'log_time' => $this->double(),
'prefix' => $this->text(),
'message' => $this->text(),
]);

$this->createIndex('idx_log_level', '{{%feedme_logs}}', 'level');
$this->createIndex('idx_log_category', '{{%feedme_logs}}', 'category');
}

protected function removeTables(): void
{
$this->dropTableIfExists('{{%feedme_feeds}}');
$this->dropTableIfExists('{{%feedme_logs}}');
}
}
42 changes: 42 additions & 0 deletions src/migrations/m240611_134740_create_logs_table.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?php

namespace craft\feedme\migrations;

use craft\db\Migration;

/**
* m240611_134740_create_logs_table migration.
*/
class m240611_134740_create_logs_table extends Migration
{
/**
* @inheritdoc
*/
public function safeUp(): bool
{
// @see \craft\feedme\migrations\m240611_134740_create_logs_table
$this->createTable('{{%feedme_logs}}', [
'id' => $this->bigPrimaryKey(),
'level' => $this->integer(),
'category' => $this->string(),
'log_time' => $this->double(),
'prefix' => $this->text(),
'message' => $this->text(),
]);

$this->createIndex('idx_log_level', '{{%feedme_logs}}', 'level');
$this->createIndex('idx_log_category', '{{%feedme_logs}}', 'category');

return true;
}

/**
* @inheritdoc
*/
public function safeDown(): bool
{
$this->dropTableIfExists('{{%feedme_logs}}');

return true;
}
}
Loading
Loading