with python a wonderful and simple example is given on using scribe with python, eg scribe_cat script. But with PHP it lacks. Further there is a thrift extension for php "thrift_protocol" . What features does it offer ? Any documentation for it?
Please help me point towards a php example of using scribe, I'm close to making one (with huge file copying, thrifting of .thrift files invloved :P ) Once successful I shall post the output/code here as well.
Rutu
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
$msg1['category'] = 'keyword';
$msg1['message'] = "This is some message for the category\n";
$msg2['category'] = 'keyword';
$msg2['message'] = "Some other message for the category\n";
$entry1 = new LogEntry($msg1);
$entry2 = new LogEntry($msg2);
$messages = array($entry1, $entry2);
$socket = new TSocket('localhost', 1464, true);
$transport = new TFramedTransport($socket);
$protocol = new TBinaryProtocol($transport, false, false);
$scribe_client = new scribeClient($protocol, $protocol);
The includes above have been arranged as required/defined by scribe in its files. I've made a complete package with the includes over here http://www.ruturaj.net/scribe-php-logging
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
It is also possible to use TSocketPool instead of TSocket to specify multiple servers, i.e:
$pool = array('1.2.3.4', '2.3.4.5', '3.4.5.6');
$socket = new TSocketPool($pool, 1464, true);
$transport = new TFramedTransport($socket);
$protocol = new TBinaryProtocol($transport, false, false);
$scribe_client = new scribeClient($protocol, $protocol);
By default, TSocketPool will randomize which server it connects to. This is fine in most situations, but I preferred to log to the first server and use the others for failover. You can turn of the randomization with:
$socket->setRandomize( false );
-Steve Corona
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
with python a wonderful and simple example is given on using scribe with python, eg scribe_cat script. But with PHP it lacks. Further there is a thrift extension for php "thrift_protocol" . What features does it offer ? Any documentation for it?
Please help me point towards a php example of using scribe, I'm close to making one (with huge file copying, thrifting of .thrift files invloved :P ) Once successful I shall post the output/code here as well.
Rutu
I've finally managed to do it !! :) Here is the script.
<code>
<?php
/*
* As found on http://highscalability.com/product-scribe-facebooks-scalable-logging-system
$messages = array();
$entry = new LogEntry;
$entry->category = "buckettest";
$entry->message = "something very interesting happened";
$messages []= $entry;
$result = $conn->Log($messages);
*/
$GLOBALS['THRIFT_ROOT'] = './includes';
include_once $GLOBALS['THRIFT_ROOT'] . '/scribe.php';
include_once $GLOBALS['THRIFT_ROOT'] . '/transport/TSocket.php';
include_once $GLOBALS['THRIFT_ROOT'] . '/transport/TFramedTransport.php';
include_once $GLOBALS['THRIFT_ROOT'] . '/protocol/TBinaryProtocol.php';
//include_once '/usr/local/src/releases/scribe-2.0/src/gen-php/scribe.php';
$msg1['category'] = 'keyword';
$msg1['message'] = "This is some message for the category\n";
$msg2['category'] = 'keyword';
$msg2['message'] = "Some other message for the category\n";
$entry1 = new LogEntry($msg1);
$entry2 = new LogEntry($msg2);
$messages = array($entry1, $entry2);
$socket = new TSocket('localhost', 1464, true);
$transport = new TFramedTransport($socket);
$protocol = new TBinaryProtocol($transport, false, false);
$scribe_client = new scribeClient($protocol, $protocol);
$transport->open();
$scribe_client->Log($messages);
$transport->close();
</code>
The includes above have been arranged as required/defined by scribe in its files. I've made a complete package with the includes over here http://www.ruturaj.net/scribe-php-logging
It is also possible to use TSocketPool instead of TSocket to specify multiple servers, i.e:
$pool = array('1.2.3.4', '2.3.4.5', '3.4.5.6');
$socket = new TSocketPool($pool, 1464, true);
$transport = new TFramedTransport($socket);
$protocol = new TBinaryProtocol($transport, false, false);
$scribe_client = new scribeClient($protocol, $protocol);
By default, TSocketPool will randomize which server it connects to. This is fine in most situations, but I preferred to log to the first server and use the others for failover. You can turn of the randomization with:
$socket->setRandomize( false );
-Steve Corona
(Also, you can specify an array of ports if the port is not the same for all machines)
-Steve