Add 2 new events to enable logger pluginization: StartLog and EndLog
This commit is contained in:
parent
51f0dd5e37
commit
2ab01e040e
11
EVENTS.txt
11
EVENTS.txt
@ -617,3 +617,14 @@ EndInlineScriptElement: After a <script...> element is written
|
|||||||
- $action
|
- $action
|
||||||
- $code
|
- $code
|
||||||
- $type
|
- $type
|
||||||
|
|
||||||
|
StartLog: Before writing to the logs
|
||||||
|
- &$priority
|
||||||
|
- &$msg
|
||||||
|
- &$filename
|
||||||
|
|
||||||
|
EndLog: After writing to the logs
|
||||||
|
- $priority
|
||||||
|
- $msg
|
||||||
|
- $filename
|
||||||
|
|
||||||
|
25
lib/util.php
25
lib/util.php
@ -1070,18 +1070,21 @@ function common_request_id()
|
|||||||
|
|
||||||
function common_log($priority, $msg, $filename=null)
|
function common_log($priority, $msg, $filename=null)
|
||||||
{
|
{
|
||||||
$msg = '[' . common_request_id() . '] ' . $msg;
|
if(Event::handle('StartLog', array(&$priority, &$msg, &$filename))){
|
||||||
$logfile = common_config('site', 'logfile');
|
$msg = '[' . common_request_id() . '] ' . $msg;
|
||||||
if ($logfile) {
|
$logfile = common_config('site', 'logfile');
|
||||||
$log = fopen($logfile, "a");
|
if ($logfile) {
|
||||||
if ($log) {
|
$log = fopen($logfile, "a");
|
||||||
$output = common_log_line($priority, $msg);
|
if ($log) {
|
||||||
fwrite($log, $output);
|
$output = common_log_line($priority, $msg);
|
||||||
fclose($log);
|
fwrite($log, $output);
|
||||||
|
fclose($log);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
common_ensure_syslog();
|
||||||
|
syslog($priority, $msg);
|
||||||
}
|
}
|
||||||
} else {
|
Event::handle('EndLog', array($priority, $msg, $filename));
|
||||||
common_ensure_syslog();
|
|
||||||
syslog($priority, $msg);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user