+<?php
+/**
+ * Created by PhpStorm.
+ * User: gg
+ * Date: 12/04/2015
+ * Time: 12:11
+ */
+
+namespace PhpXmlRpc\Helper;
+
+
+class Logger
+{
+ /**
+ * 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
+ */
+ public static function debugMessage($message, $encoding=null)
+ {
+ if (PHP_SAPI != 'cli') {
+ $flags = ENT_COMPAT | ENT_HTML401 | ENT_SUBSTITUTE;
+ if ($encoding != null) {
+ print "<PRE>\n".htmlentities($message, $flags, $encoding)."\n</PRE>";
+ } else {
+ print "<PRE>\n".htmlentities($message, $flags)."\n</PRE>";
+ }
+ } else {
+ print "\n$message\n";
+ }
+
+ // let the user see this now in case there's a time out later...
+ flush();
+ }
+}
\ No newline at end of file