diff --git a/README.md b/README.md index 9855f26..835515a 100644 --- a/README.md +++ b/README.md @@ -28,16 +28,16 @@ Usage ```php info('Well, that works!'); -MonoLogger::getLogger('myApp')->error('Maybe not...'); +Cascade::getLogger('myApp')->info('Well, that works!'); +Cascade::getLogger('myApp')->error('Maybe not...'); ``` Configuring your loggers diff --git a/examples/multiple_loggers.php b/examples/multiple_loggers.php index 832e33e..c186fb4 100644 --- a/examples/multiple_loggers.php +++ b/examples/multiple_loggers.php @@ -1,15 +1,15 @@ info('Well, that works!'); -MonoLogger::getLogger('loggerB')->error('Maybe not...'); +Cascade::fileConfig($loggerConfigFile); +Cascade::getLogger('loggerA')->info('Well, that works!'); +Cascade::getLogger('loggerB')->error('Maybe not...'); // This should log into 2 different log files depending on the level: 'example_info.log' and 'example_error.log' \ No newline at end of file diff --git a/examples/single_logger.php b/examples/single_logger.php index 8a8ab59..21a660d 100644 --- a/examples/single_logger.php +++ b/examples/single_logger.php @@ -1,9 +1,9 @@ pushHandler(new Monolog\Handler\StreamHandler('php://stdout')); $logger->info('Hellooooo World!'); diff --git a/src/MonoLogger.php b/src/Cascade.php similarity index 88% rename from src/MonoLogger.php rename to src/Cascade.php index baa1966..afd0946 100644 --- a/src/MonoLogger.php +++ b/src/Cascade.php @@ -14,7 +14,7 @@ * * @author Raphael Antonmattei */ -class MonoLogger +class Cascade { /** * Config class that holds options for all registered loggers @@ -65,6 +65,18 @@ public static function getLogger($name) return Registry::hasLogger($name) ? Registry::getInstance($name) : self::createLogger($name); } + /** + * Alias of getLogger + * @see getLogger + * + * @param string $name Name of the requested Logger instance + * @return Monolog\Logger Requested instance of Logger or new instance + */ + public static function logger($name) + { + return self::getLogger($name); + } + /** * Return the config options * diff --git a/src/Config/Loader/ClassLoader/LoggerLoader.php b/src/Config/Loader/ClassLoader/LoggerLoader.php index fd0dc84..9c56e23 100644 --- a/src/Config/Loader/ClassLoader/LoggerLoader.php +++ b/src/Config/Loader/ClassLoader/LoggerLoader.php @@ -1,7 +1,7 @@ processors = $processors; // This instanciates a Logger object and set it to the Registry - $this->logger = MonoLogger::getLogger($loggerName); + $this->logger = Cascade::getLogger($loggerName); } /** diff --git a/tests/MonoLoggerTest.php b/tests/CascadeTest.php similarity index 69% rename from tests/MonoLoggerTest.php rename to tests/CascadeTest.php index df0b9fc..71f3fc2 100644 --- a/tests/MonoLoggerTest.php +++ b/tests/CascadeTest.php @@ -4,15 +4,15 @@ use Monolog\Logger; use Monolog\Registry; -use Cascade\MonoLogger; +use Cascade\Cascade; use Cascade\Tests\Fixtures; /** - * Class MonoLoggerTest + * Class CascadeTest * * @author Raphael Antonmattei */ -class MonoLoggerTest extends \PHPUnit_Framework_TestCase +class CascadeTest extends \PHPUnit_Framework_TestCase { public function teardown() { @@ -22,7 +22,7 @@ public function teardown() public function testCreateLogger() { - $logger = MonoLogger::createLogger('test'); + $logger = Cascade::createLogger('test'); $this->assertTrue($logger instanceof Logger); $this->assertEquals('test', $logger->getName()); @@ -32,10 +32,10 @@ public function testCreateLogger() public function testRegistry() { // Creates the logger and push it to the registry - $logger = MonoLogger::getLogger('test'); + $logger = Cascade::logger('test'); // We should get the logger from the registry this time - $logger2 = MonoLogger::getLogger('test'); + $logger2 = Cascade::logger('test'); $this->assertSame($logger, $logger2); } @@ -44,13 +44,13 @@ public function testRegistry() */ public function testRegistryWithInvalidName() { - $logger = MonoLogger::getLogger(null); + $logger = Cascade::getLogger(null); } public function testFileConfig() { $options = Fixtures::getPhpArrayConfig(); - MonoLogger::fileConfig($options); - $this->assertInstanceOf('Cascade\Config', MonoLogger::getConfig()); + Cascade::fileConfig($options); + $this->assertInstanceOf('Cascade\Config', Cascade::getConfig()); } }