Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix function name logging for db queries
  • Loading branch information
mantis committed Oct 8, 2014
1 parent 475d221 commit 79a1df1
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion core/logging_api.php
Expand Up @@ -81,7 +81,23 @@ function log_event( $p_level, $p_msg ) {

# Is this called from another function?
if( isset( $t_backtrace[1] ) ) {
$t_caller .= ' ' . $t_backtrace[1]['function'] . '()';
if( $p_level == LOG_DATABASE ) {
if( isset( $t_backtrace[2] ) && $t_backtrace[2]['function'] == 'call_user_func_array' ) {
$t_caller = basename( $t_backtrace[3]['file'] );
$t_caller .= ':' . $t_backtrace[3]['line'];
$t_caller .= ' ' . $t_backtrace[3]['function'] . '()';
} else if( $t_backtrace[1]['function'] == 'db_query' ) {
$t_caller = basename( $t_backtrace[1]['file'] );
$t_caller .= ':' . $t_backtrace[1]['line'];
if( isset( $t_backtrace[2] ) ) {
$t_caller .= ' ' . $t_backtrace[2]['function'] . '()';
} else {
$t_caller .= ' ' . $t_backtrace[1]['function'] . '()';
}
}
} else {
$t_caller .= ' ' . $t_backtrace[1]['function'] . '()';
}
} else {
# or from a script directly?
$t_caller .= ' ' . $_SERVER['SCRIPT_NAME'];
Expand Down

0 comments on commit 79a1df1

Please sign in to comment.