stepotronic / logjamdispatcher
此包已被废弃,不再维护。未建议替代包。
关于此包最新版本(1.3.0)的许可信息不可用。
使用ZeroMQ将日志消息调度到logjam的基本客户端。
1.3.0
2017-05-02 14:15 UTC
Requires
- ext-zmq: ~1.1.2@beta
Requires (Dev)
- phpunit/phpunit: ^4.8
README
使用ZeroMQ将日志消息调度到logjam的基本客户端。
调度消息
use LogjamDispatcher\Dispatcher\ZmqDispatcher; use LogjamDispatcher\Logjam\Message; $dispatcher = new ZmqDispatcher(array('tcp://my.broker'), 'myapp', 'dev'); $message = new Message(); // fill message object $message->setMethod('GET'); //..... $dispatcher->dispatch($message);
使用自定义ZMQSocket初始化调度器
$dispatcher = new ZmqDispatcher(array('tcp://my.broker'), 'myapp', 'dev', ZmqDispatcher::createZmqSocket());
过滤请求信息
use LogjamDispatcher\Http\FilteredRequestInformationDecorator; use LogjamDispatcher\Http\RequestInformation; $message = new Message(); // .... $requestInformation = new RequestInformation(); $requestInformation->setBodyParameters(array( 'password' => 'foo-bar123' )); $requestInformation = new FilteredRequestInformationDecorator($requestInformation, array('password'), '*****'); print_r($requestInformation->getBodyParameters()); // outputs: Array([password] => *****) $message->setRequestInformation($requestInformation); //....
完全填充消息示例
use LogjamDispatcher\Logjam\Message; use LogjamDispatcher\Dispatcher\Expression; $message = new Message(); $requestInformation = new RequestInformation(); $requestInformation ->setMethod('GET') ->setHeaders(array('Accept' => 'Nothing', 'Feels' => 'BadMan')) ->setBodyParameters(array('action' => 'submit')) ->setQueryParameters(array('page' => '15', 'offset' => '213123')) ->setUrl('my.app.page/products'); $message ->setAction('MyApp::MyController#MyAction') ->setAdditionalData(array('stuff' => 'theUserDid')) ->setCallerAction('') //value of http request header X-Logjam-Action (if present) ->setCallerId('') //value of http request header X-Logjam-Caller-Id (if present) ->setDbCalls(12) ->setDbTime(123123.123) ->setExceptions(array($thisStupidExceptionIGot)) ->setHost('my.app.host') ->setIp('123.321.123.321') ->setRequestId(new RequestId()) ->setRequestInformation($requestInformation) ->setRequestStartedAt($myStartTimeDateTimeObject) ->setRequestEndedAt($myEndTimeDateTimeObject) ->setResponseCode(200) ->setSeverity(Expression\Severity::INFO) ->setUserId(0);
记录异常
if ($dispatcher->hasExceptions) { $exceptions = $dispatcher->getExceptions(); // Do stuff with them }