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 fff65ce7c1fb3a612d90179c4e175602c153509e..cef499b39a0f815178d212747d0b29ff42e16258 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 2369a2bc86b8dc0f261dfb921b0ccaded38733c8..cc8cf1224e053ea03da334eb156d9e87bfd40c99 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";
+        }
     }
 }
 ?>