Skip to content

Commit

Permalink
Merge pull request #71 from IWAtech/master
Browse files Browse the repository at this point in the history
added support for monolog's SyslogUdpHandler
  • Loading branch information
Seldaek committed Mar 24, 2014
2 parents e1aba3c + 97a86fe commit 78ef133
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 0 deletions.
14 changes: 14 additions & 0 deletions DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,14 @@
* - [level]: level name or int value, defaults to DEBUG
* - [bubble]: bool, defaults to true
*
* - syslogudp:
* - host: syslogd host name
* - [port]: defaults to 514
* - [facility]: defaults to LOG_USER
* - [logopts]: defaults to LOG_PID
* - [level]: level name or int value, defaults to DEBUG
* - [bubble]: bool, defaults to true
*
* - swift_mailer:
* - from_email: optional if email_prototype is given
* - to_email: optional if email_prototype is given
Expand Down Expand Up @@ -248,6 +256,8 @@ public function getConfigTreeBuilder()
->end()
->end()
->scalarNode('title')->defaultNull()->end() // pushover
->scalarNode('host')->end() // syslogudp
->scalarNode('port')->defaultValue(514)->end() // syslogudp
->arrayNode('publisher')
->canBeUnset()
->beforeNormalization()
Expand Down Expand Up @@ -475,6 +485,10 @@ public function getConfigTreeBuilder()
->ifTrue(function($v) { return 'service' === $v['type'] && !isset($v['id']); })
->thenInvalid('The id has to be specified to use a service as handler')
->end()
->validate()
->ifTrue(function($v) { return 'syslogudp' === $v['type'] && !isset($v['host']); })
->thenInvalid('The host has to be specified to use a syslogudp as handler')
->end()
->validate()
->ifTrue(function($v) { return 'gelf' === $v['type'] && !isset($v['publisher']); })
->thenInvalid('The publisher has to be specified to use a GelfHandler')
Expand Down
10 changes: 10 additions & 0 deletions DependencyInjection/MonologExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,16 @@ private function buildHandler(ContainerBuilder $container, $name, array $handler
));
break;

case 'syslogudp':
$definition->setArguments(array(
$handler['host'],
$handler['port'],
$handler['facility'],
$handler['level'],
$handler['bubble'],
));
break;

case 'swift_mailer':
$oldHandler = false;
// fallback for older symfony versions that don't have the new SwiftMailerHandler in the bridge
Expand Down
1 change: 1 addition & 0 deletions Resources/config/monolog.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
<parameter key="monolog.handler.buffer.class">Monolog\Handler\BufferHandler</parameter>
<parameter key="monolog.handler.rotating_file.class">Monolog\Handler\RotatingFileHandler</parameter>
<parameter key="monolog.handler.syslog.class">Monolog\Handler\SyslogHandler</parameter>
<parameter key="monolog.handler.syslogudp.class">Monolog\Handler\SyslogUdpHandler</parameter>
<parameter key="monolog.handler.null.class">Monolog\Handler\NullHandler</parameter>
<parameter key="monolog.handler.test.class">Monolog\Handler\TestHandler</parameter>
<parameter key="monolog.handler.gelf.class">Monolog\Handler\GelfHandler</parameter>
Expand Down
2 changes: 2 additions & 0 deletions Resources/config/schema/monolog-1.0.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
<xsd:attribute name="name" type="xsd:string" use="required" />
<xsd:attribute name="ident" type="xsd:string" />
<xsd:attribute name="facility" type="xsd:string" />
<xsd:attribute name="host" type="xsd:string" />
<xsd:attribute name="port" type="xsd:integer" />
<xsd:attribute name="action-level" type="level" />
<xsd:attribute name="buffer-size" type="xsd:integer" />
<xsd:attribute name="max-files" type="xsd:integer" />
Expand Down

0 comments on commit 78ef133

Please sign in to comment.