-
Notifications
You must be signed in to change notification settings - Fork 0
/
bwtrace.php
73 lines (66 loc) · 2.01 KB
/
bwtrace.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
<?php // (C) Copyright Bobbing Wide 2011-2015
if ( !defined( "BWTRACE_INCLUDED" ) ) {
define( "BWTRACE_INCLUDED", true );
/**
* Assume tracing is off
*/
if ( !isset( $bw_trace_on )) {
$bw_trace_on = false;
}
/**
* Log a simple trace record to the trace log file if tracing is active
*
* Use bw_trace2() in preference to bw_trace() except in special circumstances
* which prevent bw_trace2() from being invoked.
*
* @param mixed $text value to be traced
* @param string $function name of function to log in the trace file
* @param integer $lineno line number of source file to log
* @param string $file source file name
* @param string $text_label a label to help you locate the trace record
*
*/
function bw_trace( $text, $function=__FUNCTION__, $lineno=__LINE__, $file=__FILE__, $text_label=NULL) {
global $bw_trace_on;
if ( $bw_trace_on ) {
bw_lazy_trace( $text, $function, $lineno, $file, $text_label );
}
}
/**
* Trace $value to the trace log file if tracing is active
*
* @param mixed $value - the value to be traced.
* The value can be a simple field, array or complex object such as a post
* @param string $text - additional information
* @param bool $show_args - true if the parameter values are to be traced, false otherwise
* @return mixed $value - the first parameter
*/
if ( !function_exists( "bw_trace2" ) ) {
function bw_trace2( $value=NULL, $text=NULL, $show_args=true ) {
global $bw_trace_on;
if ( $bw_trace_on ) {
return( bw_lazy_trace2( $value, $text, $show_args ));
} else {
return( $value );
}
}
}
/**
* Log a debug_backtrace() to the trace log file if tracing is active
*
*/
if ( !function_exists( "bw_backtrace" ) ) {
function bw_backtrace() {
global $bw_trace_on;
if ( $bw_trace_on ) {
bw_lazy_backtrace();
}
}
}
/**
* Start up tracing from the wp-config file if required
*/
if ( defined( 'BW_TRACE_CONFIG_STARTUP' ) && BW_TRACE_CONFIG_STARTUP == true ) {
require_once( dirname( __FILE__ ) . '/bwtrace_boot.php' );
}
} /* end !defined */