See Release Notes
Long Term Support Release
<?php namespace PhpXmlRpc\Helper; /** * @todo implement an interface * @todo make constructor private to force users to go through `instance()` ? */ class Logger { 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 */ public static function instance() { if (self::$instance === null) { self::$instance = new self(); } return self::$instance; }> // *** Implement the same interface as PSR/LOG, for the sake of interoperability *** /** > * 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 > * NB: unlike other "traditional" loggers, this one echoes to screen the debug messages instead of logging them. * of 100% accuracy, which kind of defeats the purpose of debugging > * * > * @param string $message * @param string $message > * @param array $context known key: 'encoding' * @param string $encoding > * @return void */ > */ public function debugMessage($message, $encoding = null) > public function debug($message, $context = array()) { > { // US-ASCII is a warning for PHP and a fatal for HHVM > if (isset($context['encoding'])) { if ($encoding == 'US-ASCII') { > $this->debugMessage($message, $context['encoding']); $encoding = 'UTF-8'; > } else { } > $this->debugMessage($message); > } if (PHP_SAPI != 'cli') { > } $flags = ENT_COMPAT; > // avoid warnings on php < 5.4... > /** if (defined('ENT_HTML401')) { > * Following the general principle of 'never break stdout', the default behaviour $flags = $flags | ENT_HTML401; > * } > * @param string $message if (defined('ENT_SUBSTITUTE')) { > * @param $context $flags = $flags | ENT_SUBSTITUTE; > * @return void } > */ if ($encoding != null) { > public function warning($message, $context = array()) print "<PRE>\n".htmlentities($message, $flags, $encoding)."\n</PRE>"; > { } else { > $this->errorLog(preg_replace('/^XML-RPC :/', 'XML-RPC Warning: ', $message)); print "<PRE>\n".htmlentities($message, $flags)."\n</PRE>"; > } } > } else { > /** print "\n$message\n"; > * Triggers the writing of a message to php's error log } > * > * @param string $message // let the user see this now in case there's a time out later... > * @param array $context flush(); > * @return void } > */ > public function error($message, $context = array()) /** > { * Writes a message to the error log > $this->errorLog(preg_replace('/^XML-RPC :/', 'XML-RPC Error: ', $message)); * @param string $message > } */ > public function errorLog($message) > // BC interface { >< * @param string $encoding> * @param string $encoding deprecated > * @return void > * > * @internal left in purely for BC< // let the user see this now in case there's a time out later...> // let the user see this now in case there's a time-out later...< * Writes a message to the error log> * Writes a message to the error log. > *> * @return void > * > * @internal left in purely for BC