Skip to content

Commit

Permalink
Merge pull request #5 from weirdan/drop-monolog
Browse files Browse the repository at this point in the history
Drop monolog requirement
  • Loading branch information
weirdan authored Aug 16, 2018
2 parents b8887dc + 2de3934 commit ea3b27f
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
3 changes: 1 addition & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@
"require-dev": {
"phpunit/phpunit": "^5.0 || ^6.0 || ^7.0",
"ext-xdebug": "*",
"php": "~5.6 || ~7.0",
"monolog/monolog": "^1.23"
"php": "~5.6 || ~7.0"
},
"autoload-dev": {
"psr-4": {
Expand Down
21 changes: 20 additions & 1 deletion src/prepend.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,26 @@
call_user_func(function() {
$x = new \Composer\XdebugHandler\XdebugHandler('RWX');
if ($logFile = getenv('RWX_DEBUG_LOG')) {
$logger = new \Monolog\Logger('rwx', [new \Monolog\Handler\StreamHandler($logFile)]);
if (!class_exists(Logger::class, false)) {
class Logger extends \Psr\Log\AbstractLogger
{
private $filename;
public function __construct($filename)
{
$this->filename = $filename;
}
public function log($level, $message, array $context = array())
{
$formatted = '[' . $level . '] '
. $message
. " : "
. strtr(var_export($context, true), ["\r" => '', "\n" => ''])
. PHP_EOL;
file_put_contents($this->filename, $formatted, FILE_APPEND);
}
}
}
$logger = new Logger($logFile);
} else {
$logger = new \Psr\Log\NullLogger;
}
Expand Down

0 comments on commit ea3b27f

Please sign in to comment.