Skip to content
This repository was archived by the owner on Jan 11, 2022. It is now read-only.

Commit 9b9866b

Browse files
committed
Merge remote-tracking branch 'origin/develop'
2 parents 0b48fae + 7cb79a9 commit 9b9866b

File tree

3 files changed

+20
-2
lines changed

3 files changed

+20
-2
lines changed

config/graylog2.php

+6
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,12 @@
2929
'connection' => [
3030
'host' => '127.0.0.1',
3131
'port' => '12201',
32+
33+
/*
34+
* Choose between UDP and TCP transport.
35+
* UDP transports won't throw exceptions on transport errors,
36+
* but message reception by the Graylog server is not guaranteed.
37+
*/
3238
'type' => 'UDP',
3339

3440
// Set to UdpTransport::CHUNK_SIZE_LAN as a default

src/Graylog2.php

+4-2
Original file line numberDiff line numberDiff line change
@@ -122,17 +122,19 @@ private function invokeProcessors(Message $message, $exception = null, $context
122122
private function setupGraylogTransport()
123123
{
124124
// Setup the transport
125-
if ('UDP' === config('graylog2.connection.type')) {
125+
if ('UDP' === strtoupper(config('graylog2.connection.type'))) {
126126
$transport = new UdpTransport(
127127
config('graylog2.connection.host'),
128128
config('graylog2.connection.port'),
129129
config('graylog2.connection.chunk_size')
130130
);
131-
} else {
131+
} elseif ('TCP' === strtoupper(config('graylog2.connection.type'))) {
132132
$transport = new TcpTransport(
133133
config('graylog2.connection.host'),
134134
config('graylog2.connection.port')
135135
);
136+
} else {
137+
throw new \DomainException('Invalid Graylog Transport, should be set to TCP or UDP.');
136138
}
137139

138140
// Setup publisher and logger

tests/Graylog2Test.php

+10
Original file line numberDiff line numberDiff line change
@@ -127,4 +127,14 @@ public function testRequestProcessorParameters()
127127

128128
Graylog2::log('error', 'test', []);
129129
}
130+
131+
/**
132+
* Tests checking the Graylog transport configuration value.
133+
*/
134+
public function testInvalidTransportConfiguration()
135+
{
136+
Config::set('graylog2.connection.type', 'INVALID');
137+
$this->expectException(\DomainException::class);
138+
Graylog2::log('emergency', 'test', []);
139+
}
130140
}

0 commit comments

Comments
 (0)