Skip to content

Commit

Permalink
Merge pull request #3 from orukusaki/feature/fix-formatter-args
Browse files Browse the repository at this point in the history
Use reflection to pass formatter constructor args; thanks to orukusaki
  • Loading branch information
aleron75 committed Jul 9, 2015
2 parents a0972a9 + 60ea922 commit 939c43f
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions app/code/community/Aleron75/Magemonolog/Model/Logwriter.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,8 @@ public function __construct($logFile)
if (array_key_exists('formatter', $handlerValues)
&& array_key_exists('class', $handlerValues['formatter']))
{
$class = '\\Monolog\Formatter\\'.$handlerValues['formatter']['class'];
$args = $handlerValues['formatter']['args'];
$formatter = new $class($args);
$class = new ReflectionClass('\\Monolog\Formatter\\'.$handlerValues['formatter']['class']);
$formatter = $class->newInstanceArgs($handlerValues['formatter']['args']);
$handlerWrapper->setFormatter($formatter);
}

Expand Down Expand Up @@ -108,4 +107,4 @@ static public function factory($config)
{
return new self(self::_parseConfig($config));
}
}
}

0 comments on commit 939c43f

Please sign in to comment.