Add rudimentary logger

[MAILPOET-570]
This commit is contained in:
Pavel Dohnal
2018-08-27 16:58:33 +02:00
parent 9e2a4edcd0
commit 031125517e
5 changed files with 73 additions and 1 deletions

View File

@ -0,0 +1,22 @@
<?php
namespace MailPoet\Logging;
use MailPoet\Dependencies\Monolog\Handler\AbstractProcessingHandler;
use MailPoet\Models\Log;
class LogHandler extends AbstractProcessingHandler {
protected function write(array $record) {
$model = Log::create();
$model->hydrate([
'name' => $record['channel'],
'level' => $record['level'],
'message' => $record['formatted'],
'created_at' => $record['datetime']->format('Y-m-d H:i:s'),
]);
$model->save();
}
}