-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Expand file tree
/
Copy pathfunctions-debug.php
More file actions
65 lines (59 loc) · 1.47 KB
/
functions-debug.php
File metadata and controls
65 lines (59 loc) · 1.47 KB
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
<?php
/*
* Functions relative to debugging
*/
/**
* Add a message to the debug log
*
* When in debug mode (YOURLS_DEBUG == true) the debug log is echoed in yourls_html_footer()
* Log messages are appended to $ydb->debug_log array, which is instantiated within class Database\YDB
*
* @since 1.7
* @param string $msg Message to add to the debug log
* @return string The message itself
*/
function yourls_debug_log( $msg ) {
yourls_do_action( 'debug_log', $msg );
yourls_get_db('read-debug_log')->getProfiler()->getLogger()->log('debug', $msg);
return $msg;
}
/**
* Get the debug log
*
* @since 1.7.3
* @return array
*/
function yourls_get_debug_log() {
return yourls_get_db('read-get_debug_log')->getProfiler()->getLogger()->getMessages();
}
/**
* Get number of SQL queries performed
*
* @return int
*/
function yourls_get_num_queries() {
return yourls_apply_filter( 'get_num_queries', yourls_get_db('read-get_num_queries')->get_num_queries() );
}
/**
* Debug mode set
*
* @since 1.7.3
* @param bool $bool Debug on or off
* @return void
*/
function yourls_debug_mode( $bool ) {
// log queries if true
yourls_get_db('read-debug_mode')->getProfiler()->setActive( (bool)$bool );
// report notices if true
$level = $bool ? -1 : ( E_ERROR | E_PARSE );
error_reporting( $level );
}
/**
* Return YOURLS debug mode
*
* @since 1.7.7
* @return bool
*/
function yourls_get_debug_mode() {
return defined( 'YOURLS_DEBUG' ) && YOURLS_DEBUG;
}