1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of the php-gelf package. |
5
|
|
|
* |
6
|
|
|
* (c) Benjamin Zikarsky <http://benjamin-zikarsky.de> |
7
|
|
|
* |
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
9
|
|
|
* file that was distributed with this source code. |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
namespace Gelf\Transport; |
13
|
|
|
|
14
|
|
|
use Gelf\Encoder\EncoderInterface; |
15
|
|
|
use Gelf\MessageInterface; |
16
|
|
|
use Gelf\PublisherInterface; |
17
|
|
|
|
18
|
|
|
/** |
19
|
|
|
* The CompressedJsonEncoder allows the encoding of GELF messages as described |
20
|
|
|
* in http://www.graylog2.org/resources/documentation/sending/gelfhttp |
21
|
|
|
* |
22
|
|
|
* @author Benjamin Zikarsky <[email protected]> |
23
|
|
|
*/ |
24
|
|
|
abstract class AbstractTransport implements TransportInterface, PublisherInterface |
25
|
|
|
{ |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* @var EncoderInterface |
29
|
|
|
*/ |
30
|
|
|
protected $messageEncoder; |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* Sets a message encoder |
34
|
|
|
* |
35
|
|
|
* @param EncoderInterface $encoder |
36
|
|
|
* |
37
|
|
|
* @return $this |
38
|
|
|
*/ |
39
|
29 |
|
public function setMessageEncoder(EncoderInterface $encoder) |
40
|
|
|
{ |
41
|
29 |
|
$this->messageEncoder = $encoder; |
42
|
|
|
|
43
|
29 |
|
return $this; |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* Returns the current message encoder |
48
|
|
|
* |
49
|
|
|
* @return EncoderInterface |
50
|
|
|
*/ |
51
|
17 |
|
public function getMessageEncoder() |
52
|
|
|
{ |
53
|
17 |
|
return $this->messageEncoder; |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
/** |
57
|
|
|
* Alias to send() without return value |
58
|
|
|
* Required to fulfill the PublisherInterface |
59
|
|
|
* |
60
|
|
|
* @deprecated deprecated since 1.1 |
61
|
|
|
* @codeCoverageIgnore |
62
|
|
|
* |
63
|
|
|
* @param MessageInterface $message |
64
|
|
|
* |
65
|
|
|
* @return int the number of bytes sent |
66
|
|
|
*/ |
67
|
|
|
public function publish(MessageInterface $message) |
68
|
|
|
{ |
69
|
|
|
return $this->send($message); |
70
|
|
|
} |
71
|
|
|
} |
72
|
|
|
|