Skip to content

Commit 1a5fb9c

Browse files
committed
ICL: Readme section added.
1 parent 5d22c94 commit 1a5fb9c

File tree

1 file changed

+37
-1
lines changed

1 file changed

+37
-1
lines changed

README.md

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,43 @@ array:5 [
194194
195195
## Auto saving to database
196196
197-
In progress...
197+
Another cool feature available for you is notifications database storing. It is disabled by default, and available only if you're using `mysql` database connection.
198+
To enable storing notifications to database - just override `enableNotificationDbStoring` method. By default, you'll get `iclogger_notifications` table with all required notifications information.
199+
And this would be fine for most cases.
200+
201+
However, you can customize database table name and even storing logic if needed:
202+
203+
```php
204+
class Foo extends Command
205+
{
206+
use Loggable;
207+
208+
protected function enableNotificationDbStoring()
209+
{
210+
return true;
211+
}
212+
213+
protected function getNotificationDbTable()
214+
{
215+
return 'my_custom_notifications';
216+
}
217+
218+
protected function getNotificationDbCallback()
219+
{
220+
return function (array $record) {
221+
MyNotification::create([
222+
'entity' => 'some-additional-data',
223+
'level' => $record['level'],
224+
'level_name' => $record['level_name'],
225+
'message' => $record['message'],
226+
'context' => get_dump($record['context']),
227+
]);
228+
};
229+
}
230+
231+
// ...
232+
}
233+
```
198234
199235
## Advanced
200236

0 commit comments

Comments
 (0)