command line interface to update and force since feeds, feed entries and ping urls
[stapibas.git] / src / stapibas / Logger.php
index 407ebee1d7ee1e5d33bd8f03fd80146adfe78582..abe44357411dbe4972121b3d880ae56ad1128ff8 100644 (file)
@@ -3,18 +3,31 @@ namespace stapibas;
 
 class Logger
 {
+    public $debug = false;
+
     public function err($msg)
     {
-        $this->log($msg);
+        $args = func_get_args();
+        if (count($args) > 1) {
+            $msg = call_user_func_array('sprintf', $args);
+        }
+        file_put_contents('php://stderr', $msg . "\n");
     }
 
     public function info($msg)
     {
-        $this->log($msg);
+        if ($this->debug == 1) {
+            $args = func_get_args();
+            call_user_func_array(array($this, 'log'), $args);
+        }
     }
 
     public function log($msg)
     {
+        $args = func_get_args();
+        if (count($args) > 1) {
+            $msg = call_user_func_array('sprintf', $args);
+        }
         echo $msg . "\n";
     }
 }