summaryrefslogtreecommitdiff
path: root/src/Logger/EngelsystemLogger.php
diff options
context:
space:
mode:
authorIgor Scheller <igor.scheller@igorshp.de>2018-08-31 01:55:05 +0200
committerIgor Scheller <igor.scheller@igorshp.de>2018-08-31 03:24:54 +0200
commitac48332166ce28fcb1a2fc130c7f5adbc760e42d (patch)
tree1ff076a6a1c5a35b4ad73477d60cbcb77ebfd922 /src/Logger/EngelsystemLogger.php
parent9d9aa71eb736885f23c069a75c7a047b06434178 (diff)
Models: Added LogEntry model
Diffstat (limited to 'src/Logger/EngelsystemLogger.php')
-rw-r--r--src/Logger/EngelsystemLogger.php13
1 files changed, 11 insertions, 2 deletions
diff --git a/src/Logger/EngelsystemLogger.php b/src/Logger/EngelsystemLogger.php
index 1f255b69..aab8026a 100644
--- a/src/Logger/EngelsystemLogger.php
+++ b/src/Logger/EngelsystemLogger.php
@@ -2,6 +2,7 @@
namespace Engelsystem\Logger;
+use Engelsystem\Models\LogEntry;
use Psr\Log\AbstractLogger;
use Psr\Log\InvalidArgumentException;
use Psr\Log\LogLevel;
@@ -19,6 +20,14 @@ class EngelsystemLogger extends AbstractLogger
LogLevel::WARNING,
];
+ /** @var LogEntry */
+ protected $log;
+
+ public function __construct(LogEntry $log)
+ {
+ $this->log = $log;
+ }
+
/**
* Logs with an arbitrary level.
*
@@ -33,12 +42,12 @@ class EngelsystemLogger extends AbstractLogger
public function log($level, $message, array $context = [])
{
if (!$this->checkLevel($level)) {
- throw new InvalidArgumentException();
+ throw new InvalidArgumentException('Unknown log level: ' . $level);
}
$message = $this->interpolate($message, $context);
- LogEntry_create($level, $message);
+ $this->log->create(['level' => $level, 'message' => $message]);
}
/**