Skip to content

Commit

Permalink
Bugfix and update formatter
Browse files Browse the repository at this point in the history
  • Loading branch information
niksamokhvalov committed Nov 27, 2015
1 parent 1123823 commit 2426db6
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
14 changes: 10 additions & 4 deletions src/Formatter/BitrixFormatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
namespace Bex\Monolog\Formatter;

use Monolog\Formatter\FormatterInterface;
use Monolog\Logger;

/**
* @author Nik Samokhvalov <nik@samokhvalov.info>
Expand All @@ -21,18 +22,23 @@ public function format(array $record)
{
$record['item_id'] = null;
$record['level'] = static::toBitrixLevel($record['level']);

if (!empty($record['context']))
{
foreach ($record['context'] as $name => $value)
foreach ($record['context'] as $field => $value)
{
if ($name === 'item_id')
if ($field === 'item_id')
{
$record['item_id'] = $value;
}
else
{
$record['message'] .= "<br><b>" . $name . '</b>: ' . $value;
if (is_array($value))
{
$value = var_export($value, true);
}

$record['message'] .= '<br><br>' . $field . ': ' . $value;
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/Handler/BitrixHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@ public function __construct($event = null, $module = null, $level = Logger::DEBU
protected function write(array $record)
{
\CEventLog::Log(
$record['level'],
$record['formatted']['level'],
$this->getEvent(),
$this->getModule(),
$record['item_id'],
$record['message'],
$record['formatted']['item_id'],
$record['formatted']['message'],
$this->getSite()
);
}
Expand Down

0 comments on commit 2426db6

Please sign in to comment.