summaryrefslogtreecommitdiff
path: root/vendor/liuggio/statsd-php-client/src/Liuggio/StatsdClient/Sender/SysLogSender.php
blob: 537ead396fc656c8fae13a2dc3c748b48a73f830 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<?php

namespace Liuggio\StatsdClient\Sender;


Class SysLogSender implements SenderInterface
{
    private $priority;

    public function __construct($priority = LOG_INFO)
    {
        $this->priority = $priority;
    }

    /**
     * {@inheritDoc}
     */
    public function open()
    {
        syslog($this->priority, "statsd-client-open");

        return true;
    }

    /**
     * {@inheritDoc}
     */
    function write($handle, $message, $length = null)
    {
        syslog($this->priority, sprintf("statsd-client-write \"%s\" %d Bytes", $message, strlen($message)));

        return strlen($message);
    }

    /**
     * {@inheritDoc}
     */
    function close($handle)
    {
        syslog($this->priority, "statsd-client-close");
    }
}