debug callable
authorAlan Knowles <alan@roojs.com>
Mon, 24 May 2021 07:14:18 +0000 (15:14 +0800)
committerAlan Knowles <alan@roojs.com>
Mon, 24 May 2021 07:14:18 +0000 (15:14 +0800)
File/Convert.php
File/Convert/Solution.php

index ed52bab..7748e32 100644 (file)
@@ -460,7 +460,12 @@ class File_Convert
     function debug($str)
     {
         if ($this->debug) {
-            echo $string . "<br/>\n";
+            
+            if (is_callable($this->debug)) {
+                $this->debug($str);
+            } else {
+                echo $string . "<br/>\n";
+            }
         }
         $this->log[] = $str;
     }
index 3c8331f..ba4ccd0 100644 (file)
@@ -27,8 +27,11 @@ class File_Convert_Solution
     }
     function debug($str)
     {
-        if ($this->debug || php_sapi_name() == "cli") {
-            echo $str . (php_sapi_name() == "cli" ? "\n" : "<BR>\n");
+        if ($this->debug) {
+            if (is_callable($this->debug)) {
+                $this->debug($str);
+            } else {
+            echo $str."<BR>\n";
         }
         $this->log[] = $str;
     }