00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065 include_once( 'lib/ezutils/classes/ezdebug.php' );
00066 include_once( 'lib/ezutils/classes/ezini.php' );
00067
00068 class eZDebugSetting
00069 {
00070
00071
00072
00073 function eZDebugSetting()
00074 {
00075 }
00076
00077
00078
00079
00080
00081 function isConditionTrue( $conditionName, $messageType )
00082 {
00083 global $eZDebugSettingINIObject;
00084
00085 $ini =& $eZDebugSettingINIObject;
00086
00087 if ( isset( $eZDebugSettingINIObject ) and get_class( $ini ) == 'ezini' )
00088 {
00089 if ( $ini->variable( 'DebugSettings', 'ConditionDebug' ) != 'enabled' )
00090 return false;
00091 $generalSetting = 'GeneralCondition';
00092 $debugName = eZDebug::messageName( $messageType );
00093 $specificSetting = $debugName . 'Condition';
00094 if ( $ini->hasVariable( $generalSetting, $conditionName ) )
00095 return $ini->variable( $generalSetting, $conditionName ) == 'enabled';
00096 if ( $ini->hasVariable( $specificSetting, $conditionName ) )
00097 return $ini->variable( $specificSetting, $conditionName ) == 'enabled';
00098 }
00099 return false;
00100 }
00101
00102
00103
00104
00105
00106 function changeLabel( $conditionName, $label )
00107 {
00108 if ( $label == "" )
00109 return '<' . $conditionName . '>';
00110 else
00111 return $label . ' <' . $conditionName . '>';
00112 }
00113
00114
00115
00116
00117
00118 function writeNotice( $conditionName, $string, $label = "" )
00119 {
00120 if ( !eZDebugSetting::isConditionTrue( $conditionName, EZ_LEVEL_NOTICE ) )
00121 return false;
00122 eZDebug::writeNotice( $string, eZDebugSetting::changeLabel( $conditionName, $label ) );
00123 }
00124
00125
00126
00127
00128
00129 function writeWarning( $conditionName, $string, $label = "" )
00130 {
00131 if ( !eZDebugSetting::isConditionTrue( $conditionName, EZ_LEVEL_WARNING ) )
00132 return false;
00133 eZDebug::writeWarning( $string, eZDebugSetting::changeLabel( $conditionName, $label ) );
00134 }
00135
00136
00137
00138
00139
00140 function writeError( $conditionName, $string, $label = "" )
00141 {
00142 if ( !eZDebugSetting::isConditionTrue( $conditionName, EZ_LEVEL_ERROR ) )
00143 return false;
00144 eZDebug::writeError( $string, eZDebugSetting::changeLabel( $conditionName, $label ) );
00145 }
00146
00147
00148
00149
00150
00151 function writeDebug( $conditionName, $string, $label = "" )
00152 {
00153 if ( !eZDebugSetting::isConditionTrue( $conditionName, EZ_LEVEL_DEBUG ) )
00154 return false;
00155 eZDebug::writeDebug( $string, eZDebugSetting::changeLabel( $conditionName, $label ) );
00156 }
00157
00158
00159
00160
00161
00162 function addTimingPoint( $conditionName, $label = "" )
00163 {
00164 if ( !eZDebugSetting::isConditionTrue( $conditionName, EZ_LEVEL_TIMING_POINT ) )
00165 return false;
00166 eZDebug::addTimingPoint( eZDebugSetting::changeLabel( $conditionName, $label ) );
00167 }
00168
00169
00170
00171
00172
00173 function setDebugINI( $ini )
00174 {
00175 global $eZDebugSettingINIObject;
00176 $eZDebugSettingINIObject = $ini;
00177 }
00178
00179 }
00180
00181 ?>