]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Add 2 new events to enable logger pluginization: StartLog and EndLog
authorCraig Andrews <candrews@integralblue.com>
Sat, 5 Dec 2009 07:11:27 +0000 (02:11 -0500)
committerCraig Andrews <candrews@integralblue.com>
Sat, 5 Dec 2009 07:11:27 +0000 (02:11 -0500)
EVENTS.txt
lib/util.php

index a056aa0a1ece9c7362710347f24bc8a53c1af67f..e0516f8f45ebe94a9354ffc542003adeb2b94069 100644 (file)
@@ -617,3 +617,14 @@ EndInlineScriptElement: After a <script...> element is written
 - $action
 - $code
 - $type
+
+StartLog: Before writing to the logs
+- &$priority
+- &$msg
+- &$filename
+
+EndLog: After writing to the logs
+- $priority
+- $msg
+- $filename
+
index ab046e871d2bf873349e88dc3837947b58579481..14d666503734992d3aa8edc3889859505c1c75ed 100644 (file)
@@ -1070,18 +1070,21 @@ function common_request_id()
 
 function common_log($priority, $msg, $filename=null)
 {
-    $msg = '[' . common_request_id() . '] ' . $msg;
-    $logfile = common_config('site', 'logfile');
-    if ($logfile) {
-        $log = fopen($logfile, "a");
-        if ($log) {
-            $output = common_log_line($priority, $msg);
-            fwrite($log, $output);
-            fclose($log);
+    if(Event::handle('StartLog', array(&$priority, &$msg, &$filename))){
+        $msg = '[' . common_request_id() . '] ' . $msg;
+        $logfile = common_config('site', 'logfile');
+        if ($logfile) {
+            $log = fopen($logfile, "a");
+            if ($log) {
+                $output = common_log_line($priority, $msg);
+                fwrite($log, $output);
+                fclose($log);
+            }
+        } else {
+            common_ensure_syslog();
+            syslog($priority, $msg);
         }
-    } else {
-        common_ensure_syslog();
-        syslog($priority, $msg);
+        Event::handle('EndLog', array($priority, $msg, $filename));
     }
 }