File: Client.php

package info (click to toggle)
php-horde-scribe 2.0.3-6
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, sid
  • size: 108 kB
  • sloc: xml: 261; php: 34; makefile: 2
file content (47 lines) | stat: -rw-r--r-- 1,061 bytes parent folder | download | duplicates (4)
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
43
44
45
46
47
<?php
/**
 * @category Horde
 * @package  Scribe
 */

/**
 * @category Horde
 * @package  Scribe
 */
class Horde_Scribe_Client implements Horde_Scribe
{
    /**
     * @var TFramedTransport
     */
    private $_transport;

    /**
     * @var scribeClient
     */
    private $_client;

    public function connect($host = 'localhost', $port = 1463)
    {
        $socket = new TSocket($host, $port, true);
        $this->_transport = new TFramedTransport($socket);
        $protocol = new TBinaryProtocol($this->_transport, false, false);
        $this->_client = new scribeClient($protocol, $protocol);
    }

    public function log($category, $message)
    {
        $this->logMulti(array($this->makeEntry($category, $message)));
    }

    public function logMulti(array $messages)
    {
        $this->_transport->open();
        $this->_client->Log($messages);
        $this->_transport->close();
    }

    public function makeEntry($category, $message)
    {
        return new LogEntry(array('category' => $category, 'message' => $message));
    }
}