forked from theorchard/monolog-cascade
-
Notifications
You must be signed in to change notification settings - Fork 3
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 #1 from gabfr/feat/support-monolog-2
Support monolog v. 2
- Loading branch information
Showing
38 changed files
with
475 additions
and
241 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,6 +10,7 @@ env: | |
matrix: | ||
include: | ||
- php: 5.3 | ||
dist: precise | ||
- php: 5.4 | ||
env: COVERALLS=1 PHPCS=1 | ||
- php: 5.5 | ||
|
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
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 |
---|---|---|
|
@@ -10,20 +10,18 @@ | |
*/ | ||
namespace Cascade; | ||
|
||
use Cascade\Config; | ||
use Cascade\Config\ConfigLoader; | ||
use Monolog\Handler\HandlerInterface; | ||
use Monolog\Logger; | ||
use Monolog\Registry; | ||
|
||
use Cascade\Config\ConfigLoader; | ||
|
||
/** | ||
* Module class that manages Monolog Logger object | ||
* @see Logger | ||
* @see Registry | ||
* | ||
* @author Raphael Antonmattei <[email protected]> | ||
* | ||
* @see \Monolog\Logger | ||
* @see \Monolog\Registry | ||
* | ||
*/ | ||
class Cascade | ||
{ | ||
|
@@ -36,17 +34,16 @@ class Cascade | |
|
||
/** | ||
* Create a new Logger object and push it to the registry | ||
* @see Logger::__construct | ||
* | ||
* @see Monolog\Logger::__construct | ||
* @throws \InvalidArgumentException if no name is given | ||
* | ||
* @param string $name The logging channel | ||
* @param HandlerInterface[] $handlers Optional stack of handlers, the first one in the array is called first, | ||
* etc. | ||
* @param callable[] $processors Optional array of processors | ||
* @param string $name The logging channel | ||
* @param HandlerInterface[] $handlers Optional stack of handlers, the first | ||
* one in the array is called first, etc. | ||
* @param callable[] $processors Optional array of processors | ||
* | ||
* @throws \InvalidArgumentException: if no name is given | ||
* | ||
* @return Logger newly created Logger | ||
* @return Logger Newly created Logger | ||
*/ | ||
public static function createLogger( | ||
$name, | ||
|
@@ -93,22 +90,44 @@ public static function logger($name) | |
/** | ||
* Return the config options | ||
* | ||
* @return array array with configuration options | ||
* @return Config Array with configuration options | ||
*/ | ||
public static function getConfig() | ||
{ | ||
return self::$config; | ||
} | ||
|
||
/** | ||
* Load configuration options from a file or a string | ||
* Load configuration options from a file, a JSON or Yaml string or an array. | ||
* | ||
* @param string $resource path to config file or string or array | ||
* @param string|array $resource Path to config file or configuration as string or array | ||
*/ | ||
public static function fileConfig($resource) | ||
{ | ||
self::$config = new Config($resource, new ConfigLoader()); | ||
self::$config->load(); | ||
self::$config->configure(); | ||
} | ||
|
||
/** | ||
* Load configuration options from a JSON or Yaml string. Alias of fileConfig. | ||
* @see fileConfig | ||
* | ||
* @param string $configString Configuration in string form | ||
*/ | ||
public static function loadConfigFromString($configString) | ||
{ | ||
self::fileConfig($configString); | ||
} | ||
|
||
/** | ||
* Load configuration options from an array. Alias of fileConfig. | ||
* @see fileConfig | ||
* | ||
* @param array $configArray Configuration in array form | ||
*/ | ||
public static function loadConfigFromArray($configArray) | ||
{ | ||
self::fileConfig($configArray); | ||
} | ||
} |
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,22 +14,22 @@ | |
use Symfony\Component\Config\Loader\DelegatingLoader; | ||
use Symfony\Component\Config\Loader\LoaderResolver; | ||
|
||
use Cascade\Config\Loader\PhpArray as ArrayLoader; | ||
use Cascade\Config\Loader\FileLoader\PhpArray as ArrayFromFileLoader; | ||
use Cascade\Config\Loader\FileLoader\Json as JsonLoader; | ||
use Cascade\Config\Loader\FileLoader\PhpArray as ArrayFromFileLoader; | ||
use Cascade\Config\Loader\FileLoader\Yaml as YamlLoader; | ||
use Cascade\Config\Loader\PhpArray as ArrayLoader; | ||
|
||
/** | ||
* Loader class that loads Yaml, JSON and array from various resources (file, php array, string) | ||
* @see DelegatingLoader | ||
* | ||
* @author Raphael Antonmattei <[email protected]> | ||
* @see DelegatingLoader | ||
*/ | ||
class ConfigLoader extends DelegatingLoader | ||
{ | ||
/** | ||
* Locator | ||
* @var \Symfony\Component\Config\FileLocator | ||
* @var FileLocator | ||
*/ | ||
protected $locator = null; | ||
|
||
|
@@ -56,10 +56,10 @@ public function __construct() | |
/** | ||
* Loads a configuration resource: file, array, string | ||
* | ||
* @param mixed $resource resource to load | ||
* @param mixed $type not used | ||
* @param mixed $resource Resource to load | ||
* @param string|null $type Not used | ||
* | ||
* @return array array of config options | ||
* @return array Array of config options | ||
*/ | ||
public function load($resource, $type = null) | ||
{ | ||
|
Oops, something went wrong.