Simple Scribe client that wraps all of the internal thrift objects up in a simple API
authorChuck Hagenbuch <chuck@horde.org>
Sun, 30 May 2010 19:13:28 +0000 (15:13 -0400)
committerChuck Hagenbuch <chuck@horde.org>
Sun, 30 May 2010 19:13:28 +0000 (15:13 -0400)
framework/Scribe/lib/Horde/Scribe/Client.php [new file with mode: 0644]
framework/Scribe/package.xml

diff --git a/framework/Scribe/lib/Horde/Scribe/Client.php b/framework/Scribe/lib/Horde/Scribe/Client.php
new file mode 100644 (file)
index 0000000..506af10
--- /dev/null
@@ -0,0 +1,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));
+    }
+}
index 55826ff..ca93b5f 100644 (file)
@@ -37,6 +37,9 @@ http://pear.php.net/dtd/package-2.0.xsd">
   <dir name="/">
    <dir name="lib">
     <dir name="Horde">
+     <dir name="Scribe">
+      <file name="Client.php" role="php" />
+     </dir> <!-- /lib/Horde/Scribe -->
      <file name="Scribe.php" role="php" />
      <dir name="Thrift">
       <dir name="thrift_root">
@@ -64,6 +67,7 @@ http://pear.php.net/dtd/package-2.0.xsd">
  </dependencies>
  <phprelease>
   <filelist>
+   <install name="lib/Horde/Scribe/Client.php" as="Horde/Scribe/Client.php" />
    <install name="lib/Horde/Scribe.php" as="Horde/Scribe.php" />
    <install name="lib/Horde/Thrift/thrift_root/packages/scribe/scribe_types.php" as="Horde/Thrift/thrift_root/packages/scribe/scribe_types.php" />
    <install name="lib/Horde/Thrift/thrift_root/scribe.php" as="Horde/Thrift/thrift_root/scribe.php" />