-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #20 from rantonmattei/monologger
Renamed MonoLogger to Cascade + added an alias to the getLogger function
- Loading branch information
Showing
6 changed files
with
34 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,15 @@ | ||
<?php | ||
require_once(realpath(__DIR__.'/../vendor/autoload.php')); | ||
|
||
use Cascade\MonoLogger; | ||
use Cascade\Cascade; | ||
|
||
$loggerConfigFile = realpath(__DIR__.'/logger_config.yml'); | ||
|
||
// you can use json too! | ||
// $loggerConfigFile = realpath(__DIR__.'/logger_config.json'); | ||
|
||
MonoLogger::fileConfig($loggerConfigFile); | ||
MonoLogger::getLogger('loggerA')->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' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,7 +14,7 @@ | |
* | ||
* @author Raphael Antonmattei <[email protected]> | ||
*/ | ||
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 | ||
* | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 <[email protected]> | ||
*/ | ||
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()); | ||
} | ||
} |