static function log($category, $message) { require_once THRIFT_ROOT . '/Thrift.php'; require_once THRIFT_ROOT . '/protocol/TBinaryProtocol.php'; require_once THRIFT_ROOT . '/transport/TSocket.php'; require_once THRIFT_ROOT . '/transport/TFramedTransport.php'; require_once THRIFT_ROOT . '/packages/scribe/scribe.php'; switch ($category) { case 'general': case 'accounts': case 'actions': case 'status': case 'security': case 'debug': case 'history': case 'regulation': case 'specials': break; default: fatal(); } if (!is_string($message)) { if (is_array($message)) { if (!isset($message['ts'])) { $message['ts'] = time(); } if (!isset($message['client_ip'])) { $message['client_ip'] = Utils::get_client_ip(); } if (!isset($message['user_id']) && Auth::is_logged()) { $message['user_id'] = Auth::get_user_id(); } if (!isset($message['user_name']) && Auth::is_logged()) { $message['user_name'] = Auth::get_user_name(); } $oauth_client_id = Auth::get_oauth_client_id(); if (!isset($message['oauth_client_id']) && !empty($oauth_client_id)) { $message['oauth_client_id'] = $oauth_client_id; } } $message = json_encode($message); } try { $log_entry = new \LogEntry(array('category' => $category, 'message' => $message)); $messages = array($log_entry); $socket = new \TSocket(SCRIBE_HOST, SCRIBE_PORT, FALSE); $transport = new \TFramedTransport($socket); $protocol = new \TBinaryProtocolAccelerated($transport, FALSE, FALSE); $client = new \scribeClient($protocol, $protocol); $transport->open(); $client->send_log($messages); $transport->close(); } catch (\TException $e) { return FALSE; } return TRUE; }
public function __construct($input, $output = null) { parent::__construct($input, $output); }
private static function logToScribe($messages) { global $THRIFT_ROOT; require_once $THRIFT_ROOT . '/Thrift.php'; require_once $THRIFT_ROOT . '/transport/TSocket.php'; require_once $THRIFT_ROOT . '/transport/TFramedTransport.php'; require_once $THRIFT_ROOT . '/protocol/TBinaryProtocol.php'; require_once 'Scribe.php'; $entries = array(); foreach ($messages as $message) { $entries[] = new LogEntry($message); } $socket = new TSocket(Z_CONFIG::$LOG_ADDRESS, Z_CONFIG::$LOG_PORT, true); $transport = new TFramedTransport($socket); $protocol = new TBinaryProtocol($transport, false, false); $scribe = new scribeClient($protocol, $protocol); $transport->open(); $scribe->Log($entries); $transport->close(); }
<?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'] = dirname(__FILE__); 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();
public function logMulti(array $messages) { $this->_transport->open(); $this->_client->Log($messages); $this->_transport->close(); }