From 2e588f2ac82438321355ed283042b0765d3cb48e Mon Sep 17 00:00:00 2001 From: Thomas Klaner Date: Sun, 23 Mar 2014 01:34:23 +0100 Subject: [PATCH 1/2] added support for monolog's SyslogUdpHandler especially useful if you plan to use Splunk or SplunkStorm --- DependencyInjection/Configuration.php | 14 ++++++++++++++ DependencyInjection/MonologExtension.php | 10 ++++++++++ Resources/config/monolog.xml | 1 + Resources/config/schema/monolog-1.0.xsd | 2 ++ 4 files changed, 27 insertions(+) diff --git a/DependencyInjection/Configuration.php b/DependencyInjection/Configuration.php index 10c9a616..afe3a966 100644 --- a/DependencyInjection/Configuration.php +++ b/DependencyInjection/Configuration.php @@ -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 @@ -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() @@ -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') diff --git a/DependencyInjection/MonologExtension.php b/DependencyInjection/MonologExtension.php index b80d8894..4872d7fe 100644 --- a/DependencyInjection/MonologExtension.php +++ b/DependencyInjection/MonologExtension.php @@ -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 diff --git a/Resources/config/monolog.xml b/Resources/config/monolog.xml index bf745ae4..4e90e948 100644 --- a/Resources/config/monolog.xml +++ b/Resources/config/monolog.xml @@ -13,6 +13,7 @@ Monolog\Handler\BufferHandler Monolog\Handler\RotatingFileHandler Monolog\Handler\SyslogHandler + Monolog\Handler\SyslogUdpHandler Monolog\Handler\NullHandler Monolog\Handler\TestHandler Monolog\Handler\GelfHandler diff --git a/Resources/config/schema/monolog-1.0.xsd b/Resources/config/schema/monolog-1.0.xsd index 8ef32494..7f8fadeb 100644 --- a/Resources/config/schema/monolog-1.0.xsd +++ b/Resources/config/schema/monolog-1.0.xsd @@ -32,6 +32,8 @@ + + From 97a86feac8cc1cf2f4bf5d5d932d00f44e0dd91a Mon Sep 17 00:00:00 2001 From: Thomas Klaner Date: Mon, 24 Mar 2014 16:59:54 +0100 Subject: [PATCH 2/2] replaced tabs with spaces --- Resources/config/schema/monolog-1.0.xsd | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Resources/config/schema/monolog-1.0.xsd b/Resources/config/schema/monolog-1.0.xsd index 7f8fadeb..1afc0d4c 100644 --- a/Resources/config/schema/monolog-1.0.xsd +++ b/Resources/config/schema/monolog-1.0.xsd @@ -32,8 +32,8 @@ - - + +