From 0df4e38e037373eef5c4c6e351e87f5303b6f502 Mon Sep 17 00:00:00 2001 From: Alessandro Manno Date: Tue, 11 Feb 2020 17:59:45 +0100 Subject: [PATCH 1/2] Use psr/log Signed-off-by: Alessandro Manno --- composer.json | 3 ++- src/FluentLogger.php | 45 +++++++++++++++++++++++++++++++++++++++++ src/LoggerInterface.php | 2 +- 3 files changed, 48 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index c3f86e8..6615990 100644 --- a/composer.json +++ b/composer.json @@ -20,7 +20,8 @@ } ], "require": { - "php": ">=5.3.0" + "php": ">=5.3.0", + "psr/log": "^1.1" }, "require-dev": { "phpunit/phpunit": "~4.3", diff --git a/src/FluentLogger.php b/src/FluentLogger.php index 7c1176e..acbdcc1 100644 --- a/src/FluentLogger.php +++ b/src/FluentLogger.php @@ -516,4 +516,49 @@ public function getOption($key, $default = null) return $result; } + + public function emergency($message, array $context = array()) + { + return $this->post($message, array_merge(array('level' => 'emergency'), $context)); + } + + public function alert($message, array $context = array()) + { + return $this->post($message, array_merge(array('level' => 'alert'), $context)); + } + + public function critical($message, array $context = array()) + { + return $this->post($message, array_merge(array('level' => 'critical'), $context)); + } + + public function error($message, array $context = array()) + { + return $this->post($message, array_merge(array('level' => 'error'), $context)); + } + + public function warning($message, array $context = array()) + { + return $this->post($message, array_merge(array('level' => 'warning'), $context)); + } + + public function notice($message, array $context = array()) + { + return $this->post($message, array_merge(array('level' => 'notice'), $context)); + } + + public function info($message, array $context = array()) + { + return $this->post($message, array_merge(array('level' => 'info'), $context)); + } + + public function debug($message, array $context = array()) + { + return $this->post($message, array_merge(array('level' => 'debug'), $context)); + } + + public function log($level, $message, array $context = array()) + { + return $this->post($message, array_merge(array('level' => 'log'), $context)); + } } diff --git a/src/LoggerInterface.php b/src/LoggerInterface.php index 1425a83..efbb382 100644 --- a/src/LoggerInterface.php +++ b/src/LoggerInterface.php @@ -18,7 +18,7 @@ */ namespace Fluent\Logger; -interface LoggerInterface +interface LoggerInterface extends \Psr\Log\LoggerInterface { /** * @abstract From e9e9c9cfaf445aeec7c966e7b2f8b4244f65f1a6 Mon Sep 17 00:00:00 2001 From: Alessandro Manno Date: Tue, 11 Feb 2020 18:12:29 +0100 Subject: [PATCH 2/2] Added loglevel const Signed-off-by: Alessandro Manno --- src/FluentLogger.php | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/FluentLogger.php b/src/FluentLogger.php index acbdcc1..d686162 100644 --- a/src/FluentLogger.php +++ b/src/FluentLogger.php @@ -18,6 +18,8 @@ */ namespace Fluent\Logger; +use Psr\Log\LogLevel; + /** * Fluent Logger * @@ -519,46 +521,46 @@ public function getOption($key, $default = null) public function emergency($message, array $context = array()) { - return $this->post($message, array_merge(array('level' => 'emergency'), $context)); + return $this->post($message, array_merge(array('level' => LogLevel::EMERGENCY), $context)); } public function alert($message, array $context = array()) { - return $this->post($message, array_merge(array('level' => 'alert'), $context)); + return $this->post($message, array_merge(array('level' => LogLevel::ALERT), $context)); } public function critical($message, array $context = array()) { - return $this->post($message, array_merge(array('level' => 'critical'), $context)); + return $this->post($message, array_merge(array('level' => LogLevel::CRITICAL), $context)); } public function error($message, array $context = array()) { - return $this->post($message, array_merge(array('level' => 'error'), $context)); + return $this->post($message, array_merge(array('level' => LogLevel::ERROR), $context)); } public function warning($message, array $context = array()) { - return $this->post($message, array_merge(array('level' => 'warning'), $context)); + return $this->post($message, array_merge(array('level' => LogLevel::WARNING), $context)); } public function notice($message, array $context = array()) { - return $this->post($message, array_merge(array('level' => 'notice'), $context)); + return $this->post($message, array_merge(array('level' => LogLevel::NOTICE), $context)); } public function info($message, array $context = array()) { - return $this->post($message, array_merge(array('level' => 'info'), $context)); + return $this->post($message, array_merge(array('level' => LogLevel::INFO), $context)); } public function debug($message, array $context = array()) { - return $this->post($message, array_merge(array('level' => 'debug'), $context)); + return $this->post($message, array_merge(array('level' => LogLevel::DEBUG), $context)); } public function log($level, $message, array $context = array()) { - return $this->post($message, array_merge(array('level' => 'log'), $context)); + return $this->post($message, array_merge(array('level' => $level), $context)); } }