forked from XOOPS/xmf
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDebug.php
114 lines (106 loc) · 3.4 KB
/
Debug.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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
<?php
/*
You may not change or alter any portion of this comment or credits
of supporting developers from this source code or any supporting source code
which is considered copyrighted (c) material of the original comment or credit authors.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/
namespace Xmf;
/**
* Debugging tools for developers
*
* @category Xmf\Debug
* @package Xmf
* @author trabis <[email protected]>
* @author Richard Griffith <[email protected]>
* @copyright 2011-2018 XOOPS Project (https://xoops.org)
* @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html)
* @link https://xoops.org
*/
class Debug extends \Kint
{
/**
* doOnce - do some local housekeeping on first use. Any method needing this
* assist just calls every time, the one time logic is all here.
*
* @return void
*/
private static function doOnce()
{
static $done;
if (true !== $done) {
$done = true;
$class = get_called_class();
parent::$aliases[] = [$class, 'dump'];
parent::$aliases[] = [$class, 'backtrace'];
parent::$enabled_mode = true;
parent::$mode_default = \Kint::MODE_RICH;
// display output inline ::folder = false, true puts all output at bottom of window
\Kint\Renderer\RichRenderer::$folder = false;
// options: 'original' (default), 'solarized', 'solarized-dark' and 'aante-light'
\Kint\Renderer\RichRenderer::$theme = 'aante-light.css';
}
}
/**
* Dump one or more variables
*
* @param mixed $data variable(s) to dump
*
* @return void
*/
public static function dump($data = null)
{
$args = func_get_args();
static::doOnce();
forward_static_call_array(array('parent', 'dump'), $args);
}
/**
* Display debug backtrace
*
* @return void
*/
public static function backtrace()
{
static::doOnce();
static::trace();
}
/**
* start_trace - turn on xdebug trace
*
* Requires xdebug extension
*
* @param string $tracefile file name for trace file
* @param string $collect_params argument for ini_set('xdebug.collect_params',?)
* Controls display of parameters in trace output
* @param string $collect_return argument for ini_set('xdebug.collect_return',?)
* Controls display of function return value in trace
*
* @return void
*/
public static function startTrace($tracefile = '', $collect_params = '3', $collect_return = 'On')
{
if (function_exists('xdebug_start_trace')) {
ini_set('xdebug.collect_params', $collect_params);
ini_set('xdebug.collect_return', $collect_return);
if ($tracefile == '') {
$tracefile = XOOPS_VAR_PATH . '/logs/php_trace';
}
xdebug_start_trace($tracefile);
}
}
/**
* stop_trace - turn off xdebug trace
*
* Requires xdebug extension
*
* @return void
*/
public static function stopTrace()
{
if (function_exists('xdebug_stop_trace')) {
xdebug_stop_trace();
}
}
}