Skip to content

Commit 732424e

Browse files
committed
feature #264 Add timeouts to the pushover, hipchat, slack handlers (SpacePossum)
This PR was squashed before being merged into the 3.x-dev branch (closes #264). Discussion ---------- Add timeouts to the pushover, hipchat, slack handlers Commits ------- d6242d1 Add timeouts to the pushover, hipchat, slack handlers
2 parents fccb0fc + d6242d1 commit 732424e

File tree

4 files changed

+30
-5
lines changed

4 files changed

+30
-5
lines changed

.travis.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,13 @@ matrix:
2424
env: SYMFONY_VERSION="2.8.*"
2525
- php: 5.6
2626
env: SYMFONY_VERSION="3.4.*" DEPENDENCIES=dev
27-
# Test against dev versions
2827
- php: 7.1
29-
env: DEPENDENCIES=dev
3028
- php: 7.0
3129
- php: 7.1
3230
- php: 7.2
31+
# Test against dev versions
32+
- php: nightly
33+
env: DEPENDENCIES=dev
3334
allow_failures:
3435
- env: DEPENDENCIES=dev
3536

DependencyInjection/Configuration.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,8 @@
171171
* - [title]: optional title for messages, defaults to the server hostname
172172
* - [level]: level name or int value, defaults to DEBUG
173173
* - [bubble]: bool, defaults to true
174+
* - [timeout]: float
175+
* - [connection_timeout]: float
174176
*
175177
* - raven:
176178
* - dsn: connection string
@@ -196,6 +198,8 @@
196198
* - [message_format]: text or html, defaults to text
197199
* - [host]: defaults to "api.hipchat.com"
198200
* - [api_version]: defaults to "v1"
201+
* - [timeout]: float
202+
* - [connection_timeout]: float
199203
*
200204
* - slack:
201205
* - token: slack api token
@@ -207,6 +211,8 @@
207211
* - [include_extra]: bool, defaults to false
208212
* - [level]: level name or int value, defaults to DEBUG
209213
* - [bubble]: bool, defaults to true
214+
* - [timeout]: float
215+
* - [connection_timeout]: float
210216
*
211217
* - slackwebhook:
212218
* - webhook_url: slack webhook URL
@@ -542,11 +548,11 @@ public function getConfigTreeBuilder()
542548
->end()
543549
->booleanNode('lazy')->defaultValue(true)->end() // swift_mailer
544550
->scalarNode('connection_string')->end() // socket_handler
545-
->scalarNode('timeout')->end() // socket_handler & logentries
551+
->scalarNode('timeout')->end() // socket_handler, logentries, pushover, hipchat & slack
546552
->scalarNode('time')->defaultValue(60)->end() // deduplication
547553
->scalarNode('deduplication_level')->defaultValue(Logger::ERROR)->end() // deduplication
548554
->scalarNode('store')->defaultNull()->end() // deduplication
549-
->scalarNode('connection_timeout')->end() // socket_handler & logentries
555+
->scalarNode('connection_timeout')->end() // socket_handler, logentries, pushover, hipchat & slack
550556
->booleanNode('persistent')->end() // socket_handler
551557
->scalarNode('dsn')->end() // raven_handler
552558
->scalarNode('client_id')->defaultNull()->end() // raven_handler

DependencyInjection/MonologExtension.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -501,6 +501,12 @@ private function buildHandler(ContainerBuilder $container, $name, array $handler
501501
$handler['level'],
502502
$handler['bubble'],
503503
));
504+
if (isset($handler['timeout'])) {
505+
$definition->addMethodCall('setTimeout', array($handler['timeout']));
506+
}
507+
if (isset($handler['connection_timeout'])) {
508+
$definition->addMethodCall('setConnectionTimeout', array($handler['connection_timeout']));
509+
}
504510
break;
505511

506512
case 'hipchat':
@@ -516,6 +522,12 @@ private function buildHandler(ContainerBuilder $container, $name, array $handler
516522
!empty($handler['host']) ? $handler['host'] : 'api.hipchat.com',
517523
!empty($handler['api_version']) ? $handler['api_version'] : 'v1',
518524
));
525+
if (isset($handler['timeout'])) {
526+
$definition->addMethodCall('setTimeout', array($handler['timeout']));
527+
}
528+
if (isset($handler['connection_timeout'])) {
529+
$definition->addMethodCall('setConnectionTimeout', array($handler['connection_timeout']));
530+
}
519531
break;
520532

521533
case 'slack':
@@ -530,6 +542,12 @@ private function buildHandler(ContainerBuilder $container, $name, array $handler
530542
$handler['use_short_attachment'],
531543
$handler['include_extra'],
532544
));
545+
if (isset($handler['timeout'])) {
546+
$definition->addMethodCall('setTimeout', array($handler['timeout']));
547+
}
548+
if (isset($handler['connection_timeout'])) {
549+
$definition->addMethodCall('setConnectionTimeout', array($handler['connection_timeout']));
550+
}
533551
break;
534552

535553
case 'slackwebhook':

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ MonologBundle
22
=============
33

44
The `MonologBundle` provides integration of the [Monolog](https://github.com/Seldaek/monolog)
5-
library into the Symfony2 framework.
5+
library into the Symfony framework.
66

77
More information in the official [documentation](http://symfony.com/doc/current/cookbook/logging/index.html).
88

0 commit comments

Comments
 (0)