Open Monograph Press  3.3.0
Logger.php
1 <?php
2 
3 namespace PhpXmlRpc\Helper;
4 
5 class Logger
6 {
7  protected static $instance = null;
8 
14  public static function instance()
15  {
16  if (self::$instance === null) {
17  self::$instance = new self();
18  }
19 
20  return self::$instance;
21  }
22 
31  public function debugMessage($message, $encoding=null)
32  {
33  // US-ASCII is a warning for PHP and a fatal for HHVM
34  if ($encoding == 'US-ASCII') {
35  $encoding = 'UTF-8';
36  }
37 
38  if (PHP_SAPI != 'cli') {
39  $flags = ENT_COMPAT | ENT_HTML401 | ENT_SUBSTITUTE;
40  if ($encoding != null) {
41  print "<PRE>\n".htmlentities($message, $flags, $encoding)."\n</PRE>";
42  } else {
43  print "<PRE>\n".htmlentities($message, $flags)."\n</PRE>";
44  }
45  } else {
46  print "\n$message\n";
47  }
48 
49  // let the user see this now in case there's a time out later...
50  flush();
51  }
52 }
PhpXmlRpc\Helper
Definition: Charset.php:3
PhpXmlRpc\Helper\Logger\instance
static instance()
Definition: Logger.php:14
PhpXmlRpc\Helper\Logger\$instance
static $instance
Definition: Logger.php:7
PhpXmlRpc\Helper\Logger\debugMessage
debugMessage($message, $encoding=null)
Definition: Logger.php:31
PhpXmlRpc\Helper\Logger
Definition: Logger.php:5