add log file support v0.2.1
authorChristian Weiske <cweiske@cweiske.de>
Sat, 3 Dec 2016 21:32:19 +0000 (22:32 +0100)
committerChristian Weiske <cweiske@cweiske.de>
Sat, 3 Dec 2016 21:32:19 +0000 (22:32 +0100)
data/config.php.dist
src/phinde/Log.php

index fff65ce..cef499b 100644 (file)
@@ -15,6 +15,8 @@ $GLOBALS['phinde'] = array(
     ),
     //verbose output
     'debug' => true,
+    //full path to log file
+    'logfile' => null,
     //time in seconds after which URLs may be re-indexed
     'refreshtime' => 86400,
     //if directly linked URLs shall be indexed, even if they are
index 2369a2b..cc8cf12 100644 (file)
@@ -17,7 +17,16 @@ class Log
 
     public static function log($msg)
     {
-        echo $msg . "\n";
+        if (isset($GLOBALS['phinde']['logfile'])
+            && $GLOBALS['phinde']['logfile'] != ''
+        ) {
+            file_put_contents(
+                $GLOBALS['phinde']['logfile'],
+                $msg . "\n", FILE_APPEND
+            );
+        } else {
+            echo $msg . "\n";
+        }
     }
 }
 ?>