Permalink
Browse files

Move constants out to a Level class

  • Loading branch information...
1 parent f5a5360 commit f9a223acf1b8b49f2353b568e2d607e7f34fcc93 @Seldaek Seldaek committed Nov 30, 2012
Showing with 30 additions and 18 deletions.
  1. +18 −0 Psr/Log/Level.php
  2. +0 −9 Psr/Log/LoggerInterface.php
  3. +11 −8 Psr/Log/LoggerInterfaceTest.php
  4. +1 −1 composer.json
View
@@ -0,0 +1,18 @@
+<?php
+
+namespace Psr\Log;
+
+/**
+ * Describes log levels
+ */
+class Level
+{
+ const EMERGENCY = 'emergency';
+ const ALERT = 'alert';
+ const CRITICAL = 'critical';
+ const ERROR = 'error';
+ const WARNING = 'warning';
+ const NOTICE = 'notice';
+ const INFO = 'info';
+ const DEBUG = 'debug';
+}
@@ -19,15 +19,6 @@
*/
interface LoggerInterface
{
- const EMERGENCY = 'emergency';
- const ALERT = 'alert';
- const CRITICAL = 'critical';
- const ERROR = 'error';
- const WARNING = 'warning';
- const NOTICE = 'notice';
- const INFO = 'info';
- const DEBUG = 'debug';
-
/**
* System is unusable.
*
@@ -47,17 +47,20 @@ public function testLogsAtAllLevels($level, $message)
public function provideLevelsAndMessages()
{
return array(
- LoggerInterface::EMERGENCY => array(LoggerInterface::EMERGENCY, 'message of level emergency with context: %user%'),
- LoggerInterface::ALERT => array(LoggerInterface::ALERT, 'message of level alert with context: %user%'),
- LoggerInterface::CRITICAL => array(LoggerInterface::CRITICAL, 'message of level critical with context: %user%'),
- LoggerInterface::ERROR => array(LoggerInterface::ERROR, 'message of level error with context: %user%'),
- LoggerInterface::WARNING => array(LoggerInterface::WARNING, 'message of level warning with context: %user%'),
- LoggerInterface::NOTICE => array(LoggerInterface::NOTICE, 'message of level notice with context: %user%'),
- LoggerInterface::INFO => array(LoggerInterface::INFO, 'message of level info with context: %user%'),
- LoggerInterface::DEBUG => array(LoggerInterface::DEBUG, 'message of level debug with context: %user%'),
+ Level::EMERGENCY => array(Level::EMERGENCY, 'message of level emergency with context: %user%'),
+ Level::ALERT => array(Level::ALERT, 'message of level alert with context: %user%'),
+ Level::CRITICAL => array(Level::CRITICAL, 'message of level critical with context: %user%'),
+ Level::ERROR => array(Level::ERROR, 'message of level error with context: %user%'),
+ Level::WARNING => array(Level::WARNING, 'message of level warning with context: %user%'),
+ Level::NOTICE => array(Level::NOTICE, 'message of level notice with context: %user%'),
+ Level::INFO => array(Level::INFO, 'message of level info with context: %user%'),
+ Level::DEBUG => array(Level::DEBUG, 'message of level debug with context: %user%'),
);
}
+ /**
+ * @expectedException Psr\Log\InvalidArgumentException
+ */
public function testThrowsOnInvalidLevel()
{
$logger = $this->getLogger();
View
@@ -10,7 +10,7 @@
],
"autoload": {
"psr-0": {
- "Psr\\Log\\": ""
+ "PhpFig\\PsrLog\\": ""
}
}
}

0 comments on commit f9a223a

Please sign in to comment.