1
0
mirror of https://github.com/Seldaek/monolog.git synced 2025-08-05 20:57:36 +02:00
This commit is contained in:
Jordi Boggiano
2012-12-14 12:15:30 +01:00
parent 6588c1633e
commit 9c8db38385
8 changed files with 9 additions and 12 deletions

View File

@@ -147,7 +147,7 @@ Formatters
- _WildfireFormatter_: Used to format log records into the Wildfire/FirePHP protocol, only useful for the FirePHPHandler. - _WildfireFormatter_: Used to format log records into the Wildfire/FirePHP protocol, only useful for the FirePHPHandler.
- _ChromePHPFormatter_: Used to format log records into the ChromePHP format, only useful for the ChromePHPHandler. - _ChromePHPFormatter_: Used to format log records into the ChromePHP format, only useful for the ChromePHPHandler.
- _GelfFormatter_: Used to format log records into Gelf message instances, only useful for the GelfHandler. - _GelfFormatter_: Used to format log records into Gelf message instances, only useful for the GelfHandler.
- _LogstashEventFormatter_: Used to format log records into [logstash](http://logstash.net/) event json, useful for any handler listed under inputs [here](http://logstash.net/docs/1.1.1/). - _LogstashFormatter_: Used to format log records into [logstash](http://logstash.net/) event json, useful for any handler listed under inputs [here](http://logstash.net/docs/1.1.5/).
Processors Processors
---------- ----------

View File

@@ -11,10 +11,9 @@
namespace Monolog\Formatter; namespace Monolog\Formatter;
use Monolog\Logger;
/** /**
* Serializes a log message to Logstash Event Format * Serializes a log message to Logstash Event Format
*
* @see http://logstash.net/ * @see http://logstash.net/
* @see https://github.com/logstash/logstash/blob/master/lib/logstash/event.rb * @see https://github.com/logstash/logstash/blob/master/lib/logstash/event.rb
* *
@@ -66,14 +65,15 @@ class LogstashFormatter extends NormalizerFormatter
'@message' => $record['message'], '@message' => $record['message'],
'@tags' => array($record['channel']), '@tags' => array($record['channel']),
'@source' => $this->systemName '@source' => $this->systemName
); );
if (isset($this->applicationName)) { if ($this->applicationName) {
$message['@type'] = $this->applicationName; $message['@type'] = $this->applicationName;
} }
$message['@fields'] = array(); $message['@fields'] = array();
$message['@fields']['channel'] = $record['channel']; $message['@fields']['channel'] = $record['channel'];
$message['@fields']['level'] = $record['level']; $message['@fields']['level'] = $record['level'];
if (isset($record['extra']['server'])) { if (isset($record['extra']['server'])) {
$message['@source_host'] = $record['extra']['server']; $message['@source_host'] = $record['extra']['server'];
} }

View File

@@ -67,6 +67,7 @@ class BufferHandler extends AbstractHandler
$this->buffer[] = $record; $this->buffer[] = $record;
$this->bufferSize++; $this->bufferSize++;
return false === $this->bubble; return false === $this->bubble;
} }

View File

@@ -14,7 +14,6 @@ namespace Monolog\Handler;
use Monolog\Logger; use Monolog\Logger;
use Monolog\Formatter\LineFormatter; use Monolog\Formatter\LineFormatter;
/** /**
* Logs to syslog service. * Logs to syslog service.
* *

View File

@@ -89,7 +89,6 @@ class LogstashFormatterTest extends \PHPUnit_Framework_TestCase
$message = json_decode($formatter->format($record), true); $message = json_decode($formatter->format($record), true);
$message_array = $message['@fields']; $message_array = $message['@fields'];
$this->assertArrayHasKey('ctxt_from', $message_array); $this->assertArrayHasKey('ctxt_from', $message_array);
@@ -99,7 +98,6 @@ class LogstashFormatterTest extends \PHPUnit_Framework_TestCase
$formatter = new LogstashFormatter('test', null, null, 'CTX'); $formatter = new LogstashFormatter('test', null, null, 'CTX');
$message = json_decode($formatter->format($record), true); $message = json_decode($formatter->format($record), true);
$message_array = $message['@fields']; $message_array = $message['@fields'];
$this->assertArrayHasKey('CTXfrom', $message_array); $this->assertArrayHasKey('CTXfrom', $message_array);

View File

@@ -69,7 +69,7 @@ class AbstractProcessingHandlerTest extends TestCase
$handledRecord = null; $handledRecord = null;
$handler->expects($this->once()) $handler->expects($this->once())
->method('write') ->method('write')
->will($this->returnCallback(function($record) use (&$handledRecord){ ->will($this->returnCallback(function($record) use (&$handledRecord) {
$handledRecord = $record; $handledRecord = $record;
})) }))
; ;

View File

@@ -23,4 +23,3 @@ class MockMessagePublisher extends MessagePublisher
public $lastMessage = null; public $lastMessage = null;
} }

View File

@@ -196,7 +196,7 @@ class LoggerTest extends \PHPUnit_Framework_TestCase
; ;
$logger->pushHandler($handler); $logger->pushHandler($handler);
$that = $this; $that = $this;
$logger->pushProcessor(function($record) use ($that){ $logger->pushProcessor(function($record) use ($that) {
$that->fail('The processor should not be called'); $that->fail('The processor should not be called');
}); });
$logger->addAlert('test'); $logger->addAlert('test');