[Zend_Amf + Symfony + Flex] Server with Logger

07-18-2010 przez damian Zostaw odpowiedź »

After integrating Symfony with Flex through Zend_Amf, I had to debug it and I needed some logs on server side.
Below I present my LoggedAmfServer extending Zend_Amf_Server, which logs all methods called by Flex and its’ responses. You need to pass instance of sfLogger (ie. sfFileLogger) in the constructor.

logger = $l;
parent::__construct();
}

protected function _handle(Zend_Amf_Request $request) {
$responseBody = $request->getAmfBodies();
$body = current($responseBody);
if ($body !== false) {
$data = $body->getData();
if ($data instanceof Zend_Amf_Value_Messaging_RemotingMessage) {
$this->logger->log(sprintf("[Amf Request] CLIENT: [%s] OPERATION: [%s]. PARAMETERS: [%s].",
$data->clientId, $data->operation, var_export($data->body, true)));
}
}

parent::_handle($request);
}

public function handle($request = null) {
$response = parent::handle($request);

$body = current($response->getAmfBodies());
if ($body !== false) {
$data = $body->getData();
$this->logger->log(sprintf("[Amf Response] CLIENT: [%s] RESPONSE: [%s]",
$data->clientId, var_export($data->body, true)));
}

return $response;
}

}
Reklama

Dodaj komentarz

Flexmaniaks on Facebook