Exponential Basic 2.4.0.1 Exponential Basic CMS — PHP Class Reference

debug.php
Go to the documentation of this file.
1 <?php
11 final class ezpRestDebug
12 {
13 private static $instance;
14
18 private $restINI;
19
24 private $eZDebug;
25
29 private $debug;
30
34 private static $isDebugEnabled;
35
39 private function __construct()
40 {
41 $this->restINI = eZINI::instance( 'rest.ini' );
42 $this->eZDebug = eZDebug::instance();
43 $this->debug = ezcDebug::getInstance();
44 $this->debug->setOutputFormatter( new ezpRestDebugPHPFormatter() );
45 }
46
50 public static function getInstance()
51 {
52 if ( !self::$instance instanceof ezpRestDebugHandler)
53 {
54 self::$instance = new self();
55 }
56
57 return self::$instance;
58 }
59
64 public static function isDebugEnabled()
65 {
66 if( self::$isDebugEnabled === null )
67 {
68 $isEnabled = false;
69 $globalDebugEnabled = eZINI::instance()->variable( 'DebugSettings', 'DebugOutput' ) === 'enabled';
70 $localDebugEnabled = eZINI::instance( 'rest.ini' )->variable( 'DebugSettings', 'Debug' ) === 'enabled';
71
72 if( $globalDebugEnabled && $localDebugEnabled )
73 $isEnabled = true;
74
75 self::$isDebugEnabled = $isEnabled;
76 }
77 return self::$isDebugEnabled;
78 }
79
83 public function getReport()
84 {
85 $report = array();
86
87 $report['restDebug'] = $this->debug->generateOutput();
88
89 $reportEZDebug = $this->eZDebug->printReportInternal( false );
90 $report['eZDebug'] = explode( "\n", $reportEZDebug );
91
92
93 return $report;
94 }
95
99 public function updateDebugSettings()
100 {
101 $ini = eZINI::instance();
102 $debugSettings = array();
103 $debugSettings['debug-enabled'] = ( $ini->variable( 'DebugSettings', 'DebugOutput' ) == 'enabled' and
104 $this->restINI->variable( 'DebugSettings', 'Debug' ) == 'enabled' );
105 $debugSettings['debug-by-ip'] = $ini->variable( 'DebugSettings', 'DebugByIP' ) == 'enabled';
106 $debugSettings['debug-ip-list'] = $ini->variable( 'DebugSettings', 'DebugIPList' );
107
108 $logList = $ini->variable( 'DebugSettings', 'AlwaysLog' );
109 $logMap = array( 'notice' => eZDebug::LEVEL_NOTICE,
110 'warning' => eZDebug::LEVEL_WARNING,
111 'error' => eZDebug::LEVEL_ERROR,
112 'debug' => eZDebug::LEVEL_DEBUG,
113 'strict' => eZDebug::LEVEL_STRICT );
114 $debugSettings['always-log'] = array();
115 foreach ( $logMap as $name => $level )
116 {
117 $debugSettings['always-log'][$level] = in_array( $name, $logList );
118 }
119 eZDebug::updateSettings( $debugSettings );
120 }
121
127 public function __call( $method, $arguments )
128 {
129 if( self::isDebugEnabled() )
130 {
131 if ( method_exists( $this->debug, $method ) )
132 return call_user_func_array( array( $this->debug, $method ), $arguments );
133 else
134 throw new ezcBasePropertyNotFoundException( 'ezcDebug::'.$method.'()' );
135 }
136 }
137 }
138 ?>
$level
$level
Definition: admin/message.php:106
$logList
$logList
Definition: bugpreview.php:124
eZDebug
Advanced debug/log system.
Definition: ezdebug.php:58
eZDebug\LEVEL_ERROR
const LEVEL_ERROR
Definition: ezdebug.php:62
eZDebug\LEVEL_STRICT
const LEVEL_STRICT
Definition: ezdebug.php:65
eZDebug\instance
static instance()
Definition: ezdebug.php:202
eZDebug\LEVEL_WARNING
const LEVEL_WARNING
Definition: ezdebug.php:61
eZDebug\updateSettings
static updateSettings( $settings)
Definition: ezdebug.php:1133
eZDebug\LEVEL_NOTICE
const LEVEL_NOTICE
Definition: ezdebug.php:60
eZDebug\LEVEL_DEBUG
const LEVEL_DEBUG
Definition: ezdebug.php:64
eZDebug\printReportInternal
printReportInternal( $as_html=true, $returnReport=true, $allowedDebugLevels=false, $useAccumulators=true, $useTiming=true, $useIncludedFiles=false)
Definition: ezdebug.php:1425
$ini
$ini
Definition: classes/admin/linklist.php:64
ezpRestDebugPHPFormatter
Definition: php_formatter.php:12
ezpRestDebug
Definition: debug.php:12
ezpRestDebug\__construct
__construct()
Definition: debug.php:39
ezpRestDebug\$eZDebug
$eZDebug
Definition: debug.php:24
ezpRestDebug\$restINI
$restINI
Definition: debug.php:18
ezpRestDebug\$isDebugEnabled
static $isDebugEnabled
Definition: debug.php:34
ezpRestDebug\__call
__call( $method, $arguments)
Definition: debug.php:127
ezpRestDebug\getInstance
static getInstance()
Definition: debug.php:50
ezpRestDebug\getReport
getReport()
Definition: debug.php:83
ezpRestDebug\$debug
$debug
Definition: debug.php:29
ezpRestDebug\isDebugEnabled
static isDebugEnabled()
Definition: debug.php:64
ezpRestDebug\updateDebugSettings
updateDebugSettings()
Definition: debug.php:99
ezpRestDebug\$instance
static $instance
Definition: debug.php:13
$name
$name
Definition: companytypelist.php:194
$instance
$instance
Definition: orderedit.php:667
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.