|
|
@@ -13,6 +13,8 @@ namespace Monolog;
|
|
|
|
|
|
use Monolog\Handler\HandlerInterface;
|
|
|
use Monolog\Handler\StreamHandler;
|
|
|
+use Psr\Log\LoggerInterface;
|
|
|
+use Psr\Log\InvalidArgumentException;
|
|
|
|
|
|
/**
|
|
|
* Monolog log channel
|
|
|
@@ -22,7 +24,7 @@ use Monolog\Handler\StreamHandler;
|
|
|
*
|
|
|
* @author Jordi Boggiano <j.boggiano@seld.be>
|
|
|
*/
|
|
|
-class Logger
|
|
|
+class Logger implements LoggerInterface
|
|
|
{
|
|
|
/**
|
|
|
* Detailed debug information
|
|
|
@@ -206,6 +208,7 @@ class Logger
|
|
|
if (null === $handlerKey) {
|
|
|
return false;
|
|
|
}
|
|
|
+
|
|
|
// found at least one, process message and dispatch it
|
|
|
foreach ($this->processors as $processor) {
|
|
|
$record = call_user_func($processor, $record);
|
|
|
@@ -323,7 +326,7 @@ class Logger
|
|
|
public static function getLevelName($level)
|
|
|
{
|
|
|
if (!isset(static::$levels[$level])) {
|
|
|
- throw new \InvalidArgumentException('Level "'.$level.'" is not defined, use one of: '.implode(', ', array_keys(static::$levels)));
|
|
|
+ throw new InvalidArgumentException('Level "'.$level.'" is not defined, use one of: '.implode(', ', array_keys(static::$levels)));
|
|
|
}
|
|
|
|
|
|
return static::$levels[$level];
|
|
|
@@ -350,6 +353,25 @@ class Logger
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Adds a log record at an arbitrary level.
|
|
|
+ *
|
|
|
+ * This method allows for compatibility with common interfaces.
|
|
|
+ *
|
|
|
+ * @param mixed $level The log level
|
|
|
+ * @param string $message The log message
|
|
|
+ * @param array $context The log context
|
|
|
+ * @return Boolean Whether the record has been processed
|
|
|
+ */
|
|
|
+ public function log($level, $message, array $context = array())
|
|
|
+ {
|
|
|
+ if (is_string($level) && defined(__CLASS__.'::'.strtoupper($level))) {
|
|
|
+ $level = constant(__CLASS__.'::'.strtoupper($level));
|
|
|
+ }
|
|
|
+
|
|
|
+ return $this->addRecord($level, $message, $context);
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* Adds a log record at the DEBUG level.
|
|
|
*
|
|
|
@@ -406,6 +428,20 @@ class Logger
|
|
|
return $this->addRecord(static::WARNING, $message, $context);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Adds a log record at the WARNING level.
|
|
|
+ *
|
|
|
+ * This method allows for compatibility with common interfaces.
|
|
|
+ *
|
|
|
+ * @param string $message The log message
|
|
|
+ * @param array $context The log context
|
|
|
+ * @return Boolean Whether the record has been processed
|
|
|
+ */
|
|
|
+ public function warning($message, array $context = array())
|
|
|
+ {
|
|
|
+ return $this->addRecord(static::WARNING, $message, $context);
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* Adds a log record at the ERROR level.
|
|
|
*
|
|
|
@@ -420,6 +456,20 @@ class Logger
|
|
|
return $this->addRecord(static::ERROR, $message, $context);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Adds a log record at the ERROR level.
|
|
|
+ *
|
|
|
+ * This method allows for compatibility with common interfaces.
|
|
|
+ *
|
|
|
+ * @param string $message The log message
|
|
|
+ * @param array $context The log context
|
|
|
+ * @return Boolean Whether the record has been processed
|
|
|
+ */
|
|
|
+ public function error($message, array $context = array())
|
|
|
+ {
|
|
|
+ return $this->addRecord(static::ERROR, $message, $context);
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* Adds a log record at the CRITICAL level.
|
|
|
*
|
|
|
@@ -434,6 +484,20 @@ class Logger
|
|
|
return $this->addRecord(static::CRITICAL, $message, $context);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Adds a log record at the CRITICAL level.
|
|
|
+ *
|
|
|
+ * This method allows for compatibility with common interfaces.
|
|
|
+ *
|
|
|
+ * @param string $message The log message
|
|
|
+ * @param array $context The log context
|
|
|
+ * @return Boolean Whether the record has been processed
|
|
|
+ */
|
|
|
+ public function critical($message, array $context = array())
|
|
|
+ {
|
|
|
+ return $this->addRecord(static::CRITICAL, $message, $context);
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* Adds a log record at the ALERT level.
|
|
|
*
|
|
|
@@ -461,4 +525,18 @@ class Logger
|
|
|
{
|
|
|
return $this->addRecord(static::EMERGENCY, $message, $context);
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Adds a log record at the EMERGENCY level.
|
|
|
+ *
|
|
|
+ * This method allows for compatibility with common interfaces.
|
|
|
+ *
|
|
|
+ * @param string $message The log message
|
|
|
+ * @param array $context The log context
|
|
|
+ * @return Boolean Whether the record has been processed
|
|
|
+ */
|
|
|
+ public function emergency($message, array $context = array())
|
|
|
+ {
|
|
|
+ return $this->addRecord(static::EMERGENCY, $message, $context);
|
|
|
+ }
|
|
|
}
|