-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding a generic log adapter system like Guzzle
- Loading branch information
1 parent
5c2ffca
commit e2a0f10
Showing
9 changed files
with
145 additions
and
15 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Presque package. | ||
* | ||
* (c) Justin Rainbow <justin.rainbow@gmail.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Presque\Log; | ||
|
||
interface LoggerAwareInterface | ||
{ | ||
/** | ||
* Sets an instance of the LoggerInterface for this object. If the `$logger` | ||
* is null, the object must remove any current LoggerInterface assigned to it. | ||
* | ||
* @param LoggerInterface $logger | ||
*/ | ||
function setLogger(LoggerInterface $logger = null); | ||
} |
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 |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Presque package. | ||
* | ||
* (c) Justin Rainbow <justin.rainbow@gmail.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Presque\Log; | ||
|
||
interface LoggerInterface | ||
{ | ||
function log($message, $priority = LOG_INFO, $extra = null); | ||
} |
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 |
---|---|---|
@@ -0,0 +1,51 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Presque package. | ||
* | ||
* (c) Justin Rainbow <justin.rainbow@gmail.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Presque\Log; | ||
|
||
use Monolog\Logger; | ||
|
||
/** | ||
* Log adapter for Monolog | ||
* | ||
* @link https://github.com/guzzle/guzzle/blob/master/src/Guzzle/Common/Log/MonologLogAdapter.php | ||
* @link https://github.com/Seldaek/monolog | ||
*/ | ||
class MonologLogAdapter implements LoggerInterface | ||
{ | ||
/** | ||
* syslog to Monolog mappings | ||
*/ | ||
private static $mapping = array( | ||
LOG_DEBUG => Logger::DEBUG, | ||
LOG_INFO => Logger::INFO, | ||
LOG_WARNING => Logger::WARNING, | ||
LOG_ERR => Logger::ERROR, | ||
LOG_CRIT => Logger::CRITICAL, | ||
LOG_ALERT => Logger::ALERT | ||
); | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function __construct(Logger $logObject) | ||
{ | ||
$this->log = $logObject; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function log($message, $priority = LOG_INFO, $extras = null) | ||
{ | ||
$this->log->addRecord(self::$mapping[$priority], $message); | ||
} | ||
} |
Empty file.
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