unique request ID, for associating several log entries with one request

This commit is contained in:
Shish 2013-09-12 16:29:38 +01:00
parent bf8b085de6
commit 67c026e8d8

View File

@ -923,6 +923,24 @@ function log_warning( /*string*/ $section, /*string*/ $message, $flash=null, $ar
function log_error( /*string*/ $section, /*string*/ $message, $flash=null, $args=array()) {log_msg($section, SCORE_LOG_ERROR, $message, $flash, $args);}
function log_critical(/*string*/ $section, /*string*/ $message, $flash=null, $args=array()) {log_msg($section, SCORE_LOG_CRITICAL, $message, $flash, $args);}
/**
* Get a unique ID for this request, useful for grouping log messages
*/
$_request_id = null;
function get_request_id() {
global $_request_id;
if(!$_request_id) {
// not completely trustworthy, as a user can spoof this
if(@$_SERVER['HTTP_X_VARNISH']) {
$_request_id = $_SERVER['HTTP_X_VARNISH'];
}
else {
$_request_id = "P" . uniqid();
}
}
return $_request_id;
}
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\
* Things which should be in the core API *