* new: methods `Wrapper::holdObject()` and `Wrapper::getheldObject()`, allowing flexibility in storing object instances
for code-generation scenarios involving `Wrapper::wrapPhpClass` and `Wrapper::wrapPhpFunction`
+* improved: the `Logger` class now sports methods adhering to Psr\Log\LoggerInterface
+
* improved: made sure all debug output goes through the logger at response parsing time (there was one printf call left)
* improved: all the Client's `setSomething()` methods now return the client object, allowing for usage of fluent style
changed: it now returns a Response for the cases in which it previously returned false, and an array of Response
objects for the cases in which it previously returned a string
- if you subclassed the `Client` class, take care of new static variables `$requestClass` and `$responseClass`
+ - if you replaced the Logger class, take care that you will have to implement methods `error` and `debug`
- traits have been introduced for all classes dealing with Logger, XMLParser and CharsetEncoder; method `setCharsetEncoder`
is now static
protected $errorBuffer = '';
// logger API
- public function debugMessage($message, $encoding = null)
+ public function debug($message, $context = array())
{
$this->debugBuffer .= $message . "\n";
}
// logger API
- public function errorLog($message)
+ public function error($message, $context = array())
{
$this->errorBuffer .= $message . "\n";
}
$credentials = 'Authorization: Basic ' . base64_encode($username . ':' . $password) . "\r\n";
if ($authType != 1) {
/// @todo make this a proper error, i.e. return a failure
- $this->getLogger()->errorLog('XML-RPC: ' . __METHOD__ . ': warning. Only Basic auth is supported with HTTP 1.0');
+ $this->getLogger()->error('XML-RPC: ' . __METHOD__ . ': warning. Only Basic auth is supported with HTTP 1.0');
}
}
if ($proxyUsername != '') {
if ($proxyAuthType != 1) {
/// @todo make this a proper error, i.e. return a failure
- $this->getLogger()->errorLog('XML-RPC: ' . __METHOD__ . ': warning. Only Basic auth to proxy is supported with HTTP 1.0');
+ $this->getLogger()->error('XML-RPC: ' . __METHOD__ . ': warning. Only Basic auth to proxy is supported with HTTP 1.0');
}
$proxyCredentials = 'Proxy-Authorization: Basic ' . base64_encode($proxyUsername . ':' . $proxyPassword) . "\r\n";
}
$payload;
if ($this->debug > 1) {
- $this->getLogger()->debugMessage("---SENDING---\n$op\n---END---");
+ $this->getLogger()->debug("---SENDING---\n$op\n---END---");
}
$contextOptions = array();
$message .= $name . ': ' . $val . "\n";
}
$message .= '---END---';
- $this->getLogger()->debugMessage($message);
+ $this->getLogger()->debug($message);
}
if (!$result) {
// http, https
$protocol = $method;
if (strpos($protocol, ':') !== false) {
- $this->getLogger()->errorLog('XML-RPC: ' . __METHOD__ . ": warning - attempted hacking attempt?. The curl protocol requested for the call is: '$protocol'");
+ $this->getLogger()->error('XML-RPC: ' . __METHOD__ . ": warning - attempted hacking attempt?. The curl protocol requested for the call is: '$protocol'");
return false;
}
}
curl_setopt($curl, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_2_PRIOR_KNOWLEDGE);
} else {
/// @todo make this a proper error, i.e. return a failure
- $this->getLogger()->errorLog('XML-RPC: ' . __METHOD__ . ': warning. HTTP2 is not supported by the current PHP/curl install');
+ $this->getLogger()->error('XML-RPC: ' . __METHOD__ . ': warning. HTTP2 is not supported by the current PHP/curl install');
}
break;
case 'h2':
curl_setopt($curl, CURLOPT_HTTPAUTH, $authType);
} elseif ($authType != 1) {
/// @todo make this a proper error, i.e. return a failure
- $this->getLogger()->errorLog('XML-RPC: ' . __METHOD__ . ': warning. Only Basic auth is supported by the current PHP/curl install');
+ $this->getLogger()->error('XML-RPC: ' . __METHOD__ . ': warning. Only Basic auth is supported by the current PHP/curl install');
}
}
curl_setopt($curl, CURLOPT_PROXYAUTH, $proxyAuthType);
} elseif ($proxyAuthType != 1) {
/// @todo make this a proper error, i.e. return a failure
- $this->getLogger()->errorLog('XML-RPC: ' . __METHOD__ . ': warning. Only Basic auth to proxy is supported by the current PHP/curl install');
+ $this->getLogger()->error('XML-RPC: ' . __METHOD__ . ': warning. Only Basic auth to proxy is supported by the current PHP/curl install');
}
}
}
}
if ($this->debug > 1) {
- $this->getLogger()->debugMessage("---SENDING---\n$payload\n---END---");
+ $this->getLogger()->debug("---SENDING---\n$payload\n---END---");
}
return $curl;
if ($valEncoding == 'ISO-8859-1') {
$xmlVal = utf8_encode($xmlVal);
} else {
- $this->getLogger()->errorLog('XML-RPC: ' . __METHOD__ . ': invalid charset encoding of xml text: ' . $valEncoding);
+ $this->getLogger()->error('XML-RPC: ' . __METHOD__ . ': invalid charset encoding of xml text: ' . $valEncoding);
}
}
}
if ($xmlRpcParser->_xh['isf'] > 1) {
// test that $xmlrpc->_xh['value'] is an obj, too???
- $this->getLogger()->errorLog($xmlRpcParser->_xh['isf_reason']);
+ $this->getLogger()->error($xmlRpcParser->_xh['isf_reason']);
return false;
}
}
if ($data === false) {
$escapedData = '';
- $this->getLogger()->errorLog('XML-RPC: ' . __METHOD__ . ": Converting from $srcEncoding to $destEncoding via mbstring: failed...");
+ $this->getLogger()->error('XML-RPC: ' . __METHOD__ . ": Converting from $srcEncoding to $destEncoding via mbstring: failed...");
} else {
if ($srcEncoding === 'UTF-8') {
$escapedData = $data;
}
} else {
$escapedData = '';
- $this->getLogger()->errorLog('XML-RPC: ' . __METHOD__ . ": Converting from $srcEncoding to $destEncoding: not supported...");
+ $this->getLogger()->error('XML-RPC: ' . __METHOD__ . ": Converting from $srcEncoding to $destEncoding: not supported...");
}
}
// this filters out all http headers from proxy. maybe we could take them into account, too?
$data = substr($data, $bd);
} else {
- $this->getLogger()->errorLog('XML-RPC: ' . __METHOD__ . ': HTTPS via proxy error, tunnel connection possibly failed');
+ $this->getLogger()->error('XML-RPC: ' . __METHOD__ . ': HTTPS via proxy error, tunnel connection possibly failed');
throw new HttpException(PhpXmlRpc::$xmlrpcstr['http_error'] . ' (HTTPS via proxy error, tunnel connection possibly failed)', PhpXmlRpc::$xmlrpcerr['http_error']);
}
}
if ($httpResponse['status_code'] !== '200') {
$errstr = substr($data, 0, strpos($data, "\n") - 1);
- $this->getLogger()->errorLog('XML-RPC: ' . __METHOD__ . ': HTTP error, got response: ' . $errstr);
+ $this->getLogger()->error('XML-RPC: ' . __METHOD__ . ': HTTP error, got response: ' . $errstr);
throw new HttpException(PhpXmlRpc::$xmlrpcstr['http_error'] . ' (' . $errstr . ')', PhpXmlRpc::$xmlrpcerr['http_error'], null, $httpResponse['status_code']);
}
foreach ($httpResponse['cookies'] as $header => $value) {
$msg .= "COOKIE: $header={$value['value']}\n";
}
- $this->getLogger()->debugMessage($msg);
+ $this->getLogger()->debug($msg);
}
// if CURL was used for the call, http headers have been processed, and dechunking + reinflating have been carried out
// Decode chunked encoding sent by http 1.1 servers
if (isset($httpResponse['headers']['transfer-encoding']) && $httpResponse['headers']['transfer-encoding'] == 'chunked') {
if (!$data = static::decodeChunked($data)) {
- $this->getLogger()->errorLog('XML-RPC: ' . __METHOD__ . ': errors occurred when trying to rebuild the chunked data received from server');
+ $this->getLogger()->error('XML-RPC: ' . __METHOD__ . ': errors occurred when trying to rebuild the chunked data received from server');
throw new HttpException(PhpXmlRpc::$xmlrpcstr['dechunk_fail'], PhpXmlRpc::$xmlrpcerr['dechunk_fail'], null, $httpResponse['status_code']);
}
}
if ($httpResponse['headers']['content-encoding'] == 'deflate' && $degzdata = @gzuncompress($data)) {
$data = $degzdata;
if ($debug) {
- $this->getLogger()->debugMessage("---INFLATED RESPONSE---[" . strlen($data) . " chars]---\n$data\n---END---");
+ $this->getLogger()->debug("---INFLATED RESPONSE---[" . strlen($data) . " chars]---\n$data\n---END---");
}
} elseif ($httpResponse['headers']['content-encoding'] == 'gzip' && $degzdata = @gzinflate(substr($data, 10))) {
$data = $degzdata;
if ($debug) {
- $this->getLogger()->debugMessage("---INFLATED RESPONSE---[" . strlen($data) . " chars]---\n$data\n---END---");
+ $this->getLogger()->debug("---INFLATED RESPONSE---[" . strlen($data) . " chars]---\n$data\n---END---");
}
} else {
- $this->getLogger()->errorLog('XML-RPC: ' . __METHOD__ . ': errors occurred when trying to decode the deflated data received from server');
+ $this->getLogger()->error('XML-RPC: ' . __METHOD__ . ': errors occurred when trying to decode the deflated data received from server');
throw new HttpException(PhpXmlRpc::$xmlrpcstr['decompress_fail'], PhpXmlRpc::$xmlrpcerr['decompress_fail'], null, $httpResponse['status_code']);
}
} else {
- $this->getLogger()->errorLog('XML-RPC: ' . __METHOD__ . ': the server sent deflated data. Your php install must have the Zlib extension compiled in to support this.');
+ $this->getLogger()->error('XML-RPC: ' . __METHOD__ . ': the server sent deflated data. Your php install must have the Zlib extension compiled in to support this.');
throw new HttpException(PhpXmlRpc::$xmlrpcstr['cannot_decompress'], PhpXmlRpc::$xmlrpcerr['cannot_decompress'], null, $httpResponse['status_code']);
}
}
protected static $instance = null;
/**
- * This class can be used as singleton, so that later we can move to DI patterns.
+ * This class can be used as singleton, so that later we can move to DI patterns (ish...)
*
* @return Logger
*/
return self::$instance;
}
+ // *** Implement the same interface as PSR/LOG, for the sake of interoperability ***
+
+ /**
+ * NB: unlike other "traditional" loggers, this one echoes to screen the debug messages instead of logging them.
+ *
+ * @param string $message
+ * @param array $context known key: 'encoding'
+ * @return void
+ */
+ public function debug($message, $context = array())
+ {
+ if (isset($context['encoding'])) {
+ $this->debugMessage($message, $context['encoding']);
+ } else {
+ $this->debugMessage($message);
+ }
+ }
+
+ /**
+ * Triggers the writing of a message to php's error log
+ *
+ * @param string $message
+ * @param array $context
+ * @return void
+ */
+ public function error($message, $context = array())
+ {
+ $this->errorLog($message);
+ }
+
+ // BC interface
+
/**
* Echoes a debug message, taking care of escaping it when not in console mode.
* NB: if the encoding of the message is not known or wrong, and we are working in web mode, there is no guarantee
* of 100% accuracy, which kind of defeats the purpose of debugging
*
* @param string $message
- * @param string $encoding
+ * @param string $encoding deprecated
* @return void
+ *
+ * @internal left in purely for BC
*/
public function debugMessage($message, $encoding = null)
{
/**
* Writes a message to the error log.
+ *
* @param string $message
* @return void
+ *
+ * @internal left in purely for BC
*/
public function errorLog($message)
{
if (function_exists('mb_convert_encoding')) {
$this->current_parsing_options['target_charset'] = $val;
} else {
- $this->getLogger()->errorLog('XML-RPC: ' . __METHOD__ . ": 'target_charset' option is unsupported without mbstring");
+ $this->getLogger()->error('XML-RPC: ' . __METHOD__ . ": 'target_charset' option is unsupported without mbstring");
}
break;
//$this->_xh['isf'] = 4;
//$this->_xh['isf_reason'] = "Callback passed as 'methodname_callback' is not callable";
//return;
- $this->getLogger()->errorLog('XML-RPC: ' . __METHOD__ . ": Callback passed as 'methodname_callback' is not callable");
+ $this->getLogger()->error('XML-RPC: ' . __METHOD__ . ": Callback passed as 'methodname_callback' is not callable");
}
break;
break;
default:
- $this->getLogger()->errorLog('XML-RPC: ' . __METHOD__ . ": unsupported option: $key");
+ $this->getLogger()->error('XML-RPC: ' . __METHOD__ . ": unsupported option: $key");
}
unset($mergedOptions[$key]);
}
$this->_xh['isf_reason'] = 'Invalid data received in BOOLEAN value: ' . $this->truncateForLog($this->_xh['ac']);
return;
} else {
- $this->getLogger()->errorLog('XML-RPC: ' . __METHOD__ . ': invalid data received in BOOLEAN value: ' .
+ $this->getLogger()->error('XML-RPC: ' . __METHOD__ . ': invalid data received in BOOLEAN value: ' .
$this->truncateForLog($this->_xh['ac']));
}
}
$this->_xh['isf_reason'] = 'Non numeric data received in INT value: ' . $this->truncateForLog($this->_xh['ac']);
return;
} else {
- $this->getLogger()->errorLog('XML-RPC: ' . __METHOD__ . ': non numeric data received in INT: ' .
+ $this->getLogger()->error('XML-RPC: ' . __METHOD__ . ': non numeric data received in INT: ' .
$this->truncateForLog($this->_xh['ac']));
}
/// @todo: find a better way of reporting an error value than this! Use NaN?
$this->truncateForLog($this->_xh['ac']);
return;
} else {
- $this->getLogger()->errorLog('XML-RPC: ' . __METHOD__ . ': non numeric data received in DOUBLE value: ' .
+ $this->getLogger()->error('XML-RPC: ' . __METHOD__ . ': non numeric data received in DOUBLE value: ' .
$this->truncateForLog($this->_xh['ac']));
}
$this->_xh['isf_reason'] = 'Invalid data received in DATETIME value: ' . $this->truncateForLog($this->_xh['ac']);
return;
} else {
- $this->getLogger()->errorLog('XML-RPC: ' . __METHOD__ . ': invalid data received in DATETIME value: ' .
+ $this->getLogger()->error('XML-RPC: ' . __METHOD__ . ': invalid data received in DATETIME value: ' .
$this->truncateForLog($this->_xh['ac']));
}
}
$this->_xh['value'] = new \DateTime($this->_xh['ac']);
} catch(\Exception $e) {
// q: what to do? we can not guarantee that a valid date can be created. Return null or throw?
- $this->getLogger()->errorLog('XML-RPC: ' . __METHOD__ . ': ' . $e->getMessage());
+ $this->getLogger()->error('XML-RPC: ' . __METHOD__ . ': ' . $e->getMessage());
$this->_xh['value'] = null;
}
} else {
$v = base64_decode($this->_xh['ac']);
if ($v === '' && $this->_xh['ac'] !== '') {
// only the empty string should decode to the empty string
- $this->getLogger()->errorLog('XML-RPC: ' . __METHOD__ . ': invalid data received in BASE64 value: ' .
+ $this->getLogger()->error('XML-RPC: ' . __METHOD__ . ': invalid data received in BASE64 value: ' .
$this->truncateForLog($this->_xh['ac']));
}
}
$this->_xh['isf_reason'] = 'Missing NAME inside STRUCT in received xml';
return;
} else {
- $this->getLogger()->errorLog('XML-RPC: ' . __METHOD__ . ': missing NAME inside STRUCT in received xml');
+ $this->getLogger()->error('XML-RPC: ' . __METHOD__ . ': missing NAME inside STRUCT in received xml');
}
$this->_xh['valuestack'][$vscount - 1]['name'] = '';
}
$this->_xh['isf_reason'] = 'Missing VALUE inside STRUCT in received xml';
return;
} else {
- $this->getLogger()->errorLog('XML-RPC: ' . __METHOD__ . ': missing VALUE inside STRUCT in received xml');
+ $this->getLogger()->error('XML-RPC: ' . __METHOD__ . ': missing VALUE inside STRUCT in received xml');
}
}
break;
$this->_xh['isf_reason'] = 'Missing VALUE inside PARAM in received xml';
return;
} else {
- $this->getLogger()->errorLog('XML-RPC: ' . __METHOD__ . ': missing VALUE inside PARAM in received xml');
+ $this->getLogger()->error('XML-RPC: ' . __METHOD__ . ': missing VALUE inside PARAM in received xml');
}
}
break;
$this->_xh['isf_reason'] = 'Invalid data received in METHODNAME: '. $this->truncateForLog($this->_xh['ac']);
return;
} else {
- $this->getLogger()->errorLog('XML-RPC: ' . __METHOD__ . ': invalid data received in METHODNAME: '.
+ $this->getLogger()->error('XML-RPC: ' . __METHOD__ . ': invalid data received in METHODNAME: '.
$this->truncateForLog($this->_xh['ac']));
}
}
public function parseResponse($data = '', $headersProcessed = false, $returnType = XMLParser::RETURN_XMLRPCVALS)
{
if ($this->debug > 0) {
- $this->getLogger()->debugMessage("---GOT---\n$data\n---END---");
+ $this->getLogger()->debug("---GOT---\n$data\n---END---");
}
$httpResponse = array('raw_data' => $data, 'headers' => array(), 'cookies' => array());
$this->httpResponse = $httpResponse;
if ($data == '') {
- $this->getLogger()->errorLog('XML-RPC: ' . __METHOD__ . ': no response received from server.');
+ $this->getLogger()->error('XML-RPC: ' . __METHOD__ . ': no response received from server.');
return new Response(0, PhpXmlRpc::$xmlrpcerr['no_data'], PhpXmlRpc::$xmlrpcstr['no_data']);
}
$start += strlen('<!-- SERVER DEBUG INFO (BASE64 ENCODED):');
$end = strpos($data, '-->', $start);
$comments = substr($data, $start, $end - $start);
- $this->getLogger()->debugMessage("---SERVER DEBUG INFO (DECODED) ---\n\t" .
- str_replace("\n", "\n\t", base64_decode($comments)) . "\n---END---", $respEncoding);
+ $this->getLogger()->debug("---SERVER DEBUG INFO (DECODED) ---\n\t" .
+ str_replace("\n", "\n\t", base64_decode($comments)) . "\n---END---", array('encoding' => $respEncoding));
}
}
if ($respEncoding == 'ISO-8859-1') {
$data = utf8_encode($data);
} else {
- $this->getLogger()->errorLog('XML-RPC: ' . __METHOD__ . ': unsupported charset encoding of received response: ' . $respEncoding);
+ $this->getLogger()->error('XML-RPC: ' . __METHOD__ . ': unsupported charset encoding of received response: ' . $respEncoding);
}
}
}
);
if ($this->debug > 0) {
- $this->getLogger()->debugMessage($xmlRpcParser->_xh['isf_reason']);
+ $this->getLogger()->debug($xmlRpcParser->_xh['isf_reason']);
}
}
// second error check: xml well-formed but not xml-rpc compliant
/// @todo echo something for the user? check if this was already done by the parser...
//if ($this->debug > 0) {
- // $this->getLogger()->debugMessage($xmlRpcParser->_xh['isf_reason']);
+ // $this->getLogger()->debug($xmlRpcParser->_xh['isf_reason']);
//}
}
// third error check: parsing of the response has somehow gone boink.
/// @todo echo something for the user?
} else {
if ($this->debug > 1) {
- $this->getLogger()->debugMessage(
+ $this->getLogger()->debug(
"---PARSED---\n".var_export($xmlRpcParser->_xh['value'], true)."\n---END---"
);
}
header('Content-Length: ' . (int)strlen($payload));
}
} else {
- $this->getLogger()->errorLog('XML-RPC: ' . __METHOD__ . ': http headers already sent before response is fully generated. Check for php warning or error messages');
+ $this->getLogger()->error('XML-RPC: ' . __METHOD__ . ': http headers already sent before response is fully generated. Check for php warning or error messages');
}
print $payload;
// check if $_SERVER is populated: it might have been disabled via ini file
// (this is true even when in CLI mode)
if (count($_SERVER) == 0) {
- $this->getLogger()->errorLog('XML-RPC: ' . __METHOD__ . ': cannot parse request headers as $_SERVER is not populated');
+ $this->getLogger()->error('XML-RPC: ' . __METHOD__ . ': cannot parse request headers as $_SERVER is not populated');
}
if ($this->debug > 1) {
if ($reqEncoding == 'ISO-8859-1') {
$data = utf8_encode($data);
} else {
- $this->getLogger()->errorLog('XML-RPC: ' . __METHOD__ . ': unsupported charset encoding of received request: ' . $reqEncoding);
+ $this->getLogger()->error('XML-RPC: ' . __METHOD__ . ': unsupported charset encoding of received request: ' . $reqEncoding);
}
}
}
// verify that function to be invoked is in fact callable
if (!is_callable($func)) {
- $this->getLogger()->errorLog("XML-RPC: " . __METHOD__ . ": function '$funcName' registered as method handler is not callable");
+ $this->getLogger()->error("XML-RPC: " . __METHOD__ . ": function '$funcName' registered as method handler is not callable");
return new Response(
0,
PhpXmlRpc::$xmlrpcerr['server_error'],
$r = call_user_func($func, $req);
}
if (!is_a($r, 'PhpXmlRpc\Response')) {
- $this->getLogger()->errorLog("XML-RPC: " . __METHOD__ . ": function '$funcName' registered as method handler does not return an xmlrpc response object but a " . gettype($r));
+ $this->getLogger()->error("XML-RPC: " . __METHOD__ . ": function '$funcName' registered as method handler does not return an xmlrpc response object but a " . gettype($r));
if (is_a($r, 'PhpXmlRpc\Value')) {
$r = new Response($r);
} else {
// The previous error handler was the default: all we should do is log error
// to the default error log (if level high enough)
if (ini_get('log_errors') && (intval(ini_get('error_reporting')) & $errCode)) {
+ // sadly we can't use the functionality of LoggerAware, because this is a static method
if (self::$logger === null) {
self::$logger = Logger::instance();
}
- self::$logger->errorLog($errString);
+ self::$logger->error($errString);
}
} else {
// Pass control on to previous error handler, trying to avoid loops...
$this->me['struct'] = $val;
break;
default:
- $this->getLogger()->errorLog("XML-RPC: " . __METHOD__ . ": not a known type ($type)");
+ $this->getLogger()->error("XML-RPC: " . __METHOD__ . ": not a known type ($type)");
}
}
}
}
if ($typeOf !== 1) {
- $this->getLogger()->errorLog("XML-RPC: " . __METHOD__ . ": not a scalar type ($type)");
+ $this->getLogger()->error("XML-RPC: " . __METHOD__ . ": not a scalar type ($type)");
return 0;
}
switch ($this->mytype) {
case 1:
- $this->getLogger()->errorLog('XML-RPC: ' . __METHOD__ . ': scalar xmlrpc value can have only one value');
+ $this->getLogger()->error('XML-RPC: ' . __METHOD__ . ': scalar xmlrpc value can have only one value');
return 0;
case 3:
- $this->getLogger()->errorLog('XML-RPC: ' . __METHOD__ . ': cannot add anonymous scalar to struct xmlrpc value');
+ $this->getLogger()->error('XML-RPC: ' . __METHOD__ . ': cannot add anonymous scalar to struct xmlrpc value');
return 0;
case 2:
// we're adding a scalar value to an array here
return 1;
} else {
- $this->getLogger()->errorLog('XML-RPC: ' . __METHOD__ . ': already initialized as a [' . $this->kindOf() . ']');
+ $this->getLogger()->error('XML-RPC: ' . __METHOD__ . ': already initialized as a [' . $this->kindOf() . ']');
return 0;
}
}
return 1;
} else {
- $this->getLogger()->errorLog('XML-RPC: ' . __METHOD__ . ': already initialized as a [' . $this->kindOf() . ']');
+ $this->getLogger()->error('XML-RPC: ' . __METHOD__ . ': already initialized as a [' . $this->kindOf() . ']');
return 0;
}
}
}
if (is_array($callable)) {
if (count($callable) < 2 || (!is_string($callable[0]) && !is_object($callable[0]))) {
- $this->getLogger()->errorLog('XML-RPC: ' . __METHOD__ . ': syntax for function to be wrapped is wrong');
+ $this->getLogger()->error('XML-RPC: ' . __METHOD__ . ': syntax for function to be wrapped is wrong');
return false;
}
if (is_string($callable[0])) {
} else if ($callable instanceof \Closure) {
// we do not support creating code which wraps closures, as php does not allow to serialize them
if (!$buildIt) {
- $this->getLogger()->errorLog('XML-RPC: ' . __METHOD__ . ': a closure can not be wrapped in generated source code');
+ $this->getLogger()->error('XML-RPC: ' . __METHOD__ . ': a closure can not be wrapped in generated source code');
return false;
}
}
if (!$exists) {
- $this->getLogger()->errorLog('XML-RPC: ' . __METHOD__ . ': function to be wrapped is not defined: ' . $plainFuncName);
+ $this->getLogger()->error('XML-RPC: ' . __METHOD__ . ': function to be wrapped is not defined: ' . $plainFuncName);
return false;
}
if (is_array($callable)) {
$func = new \ReflectionMethod($callable[0], $callable[1]);
if ($func->isPrivate()) {
- $this->getLogger()->errorLog('XML-RPC: ' . __METHOD__ . ': method to be wrapped is private: ' . $plainFuncName);
+ $this->getLogger()->error('XML-RPC: ' . __METHOD__ . ': method to be wrapped is private: ' . $plainFuncName);
return false;
}
if ($func->isProtected()) {
- $this->getLogger()->errorLog('XML-RPC: ' . __METHOD__ . ': method to be wrapped is protected: ' . $plainFuncName);
+ $this->getLogger()->error('XML-RPC: ' . __METHOD__ . ': method to be wrapped is protected: ' . $plainFuncName);
return false;
}
if ($func->isConstructor()) {
- $this->getLogger()->errorLog('XML-RPC: ' . __METHOD__ . ': method to be wrapped is the constructor: ' . $plainFuncName);
+ $this->getLogger()->error('XML-RPC: ' . __METHOD__ . ': method to be wrapped is the constructor: ' . $plainFuncName);
return false;
}
if ($func->isDestructor()) {
- $this->getLogger()->errorLog('XML-RPC: ' . __METHOD__ . ': method to be wrapped is the destructor: ' . $plainFuncName);
+ $this->getLogger()->error('XML-RPC: ' . __METHOD__ . ': method to be wrapped is the destructor: ' . $plainFuncName);
return false;
}
if ($func->isAbstract()) {
- $this->getLogger()->errorLog('XML-RPC: ' . __METHOD__ . ': method to be wrapped is abstract: ' . $plainFuncName);
+ $this->getLogger()->error('XML-RPC: ' . __METHOD__ . ': method to be wrapped is abstract: ' . $plainFuncName);
return false;
}
/// @todo add more checks for static vs. nonstatic?
if ($func->isInternal()) {
/// @todo from PHP 5.1.0 onward, we should be able to use invokeargs instead of getparameters to fully
/// reflect internal php functions
- $this->getLogger()->errorLog('XML-RPC: ' . __METHOD__ . ': function to be wrapped is internal: ' . $plainFuncName);
+ $this->getLogger()->error('XML-RPC: ' . __METHOD__ . ': function to be wrapped is internal: ' . $plainFuncName);
return false;
}
$client->setDebug($debug);
$response = $client->send($req, $timeout, $protocol);
if ($response->faultCode()) {
- $this->getLogger()->errorLog('XML-RPC: ' . __METHOD__ . ': could not retrieve method signature from remote server for method ' . $methodName);
+ $this->getLogger()->error('XML-RPC: ' . __METHOD__ . ': could not retrieve method signature from remote server for method ' . $methodName);
return false;
}
}
if (!is_array($mSig) || count($mSig) <= $sigNum) {
- $this->getLogger()->errorLog('XML-RPC: ' . __METHOD__ . ': could not retrieve method signature nr.' . $sigNum . ' from remote server for method ' . $methodName);
+ $this->getLogger()->error('XML-RPC: ' . __METHOD__ . ': could not retrieve method signature nr.' . $sigNum . ' from remote server for method ' . $methodName);
return false;
}
$req = new $reqClass('system.listMethods');
$response = $client->send($req, $timeout, $protocol);
if ($response->faultCode()) {
- $this->getLogger()->errorLog('XML-RPC: ' . __METHOD__ . ': could not retrieve method list from remote server');
+ $this->getLogger()->error('XML-RPC: ' . __METHOD__ . ': could not retrieve method list from remote server');
return false;
}
$mList = $decoder->decode($mList);
}
if (!is_array($mList) || !count($mList)) {
- $this->getLogger()->errorLog('XML-RPC: ' . __METHOD__ . ': could not retrieve meaningful method list from remote server');
+ $this->getLogger()->error('XML-RPC: ' . __METHOD__ . ': could not retrieve meaningful method list from remote server');
return false;
}
}
} else {
- $this->getLogger()->errorLog('XML-RPC: ' . __METHOD__ . ': will not create class method to wrap remote method ' . $mName);
+ $this->getLogger()->error('XML-RPC: ' . __METHOD__ . ': will not create class method to wrap remote method ' . $mName);
}
}
}
if ($allOK) {
return $xmlrpcClassName;
} else {
- $this->getLogger()->errorLog('XML-RPC: ' . __METHOD__ . ': could not create class ' . $xmlrpcClassName . ' to wrap remote server ' . $client->server);
+ $this->getLogger()->error('XML-RPC: ' . __METHOD__ . ': could not create class ' . $xmlrpcClassName . ' to wrap remote server ' . $client->server);
return false;
}
} else {
// logger API
- public function debugMessage($message, $encoding = null)
+ public function debug($message, $context = array())
{
$this->debugBuffer .= $message;
}
- public function errorLog($message)
+ public function error($message, $context = array())
{
$this->errorBuffer .= $message;
}