[ Index ] |
|
Code source de eZ Publish 3.9.0 |
1 <?php 2 // 3 // Definition of eZDebugSetting class 4 // 5 // Created on: <16-Jan-2003 16:23:58 amos> 6 // 7 // SOFTWARE NAME: eZ publish 8 // SOFTWARE RELEASE: 3.9.0 9 // BUILD VERSION: 17785 10 // COPYRIGHT NOTICE: Copyright (C) 1999-2006 eZ systems AS 11 // SOFTWARE LICENSE: GNU General Public License v2.0 12 // NOTICE: > 13 // This program is free software; you can redistribute it and/or 14 // modify it under the terms of version 2.0 of the GNU General 15 // Public License as published by the Free Software Foundation. 16 // 17 // This program is distributed in the hope that it will be useful, 18 // but WITHOUT ANY WARRANTY; without even the implied warranty of 19 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 // GNU General Public License for more details. 21 // 22 // You should have received a copy of version 2.0 of the GNU General 23 // Public License along with this program; if not, write to the Free 24 // Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 25 // MA 02110-1301, USA. 26 // 27 // 28 29 /*! \file ezdebugsetting.php 30 */ 31 32 /*! 33 \class eZDebugSetting ezdebugsetting.php 34 \brief Conditional debug output 35 36 This works as a wrapper for the eZDebug class by checking some 37 conditions defined in site.ini before writing the message. 38 The condition must be true for the message to be written. 39 40 It will check the debug.ini file and first see if conditions are 41 enabled globally by reading DebugSettings/ConditionDebug. 42 If true if will then see if the condition exists in the GeneralCondition 43 group, if so it will use it for condition check. 44 If it doesn't exists generally it will check it specifically according 45 to the message type for instance ErrorCondition, DebugCondition etc. 46 47 Example of debug.ini: 48 \code 49 [DebugSettings] 50 ConditionDebug=enabled 51 52 [GeneralCondition] 53 my-flag=enabled 54 other-flag=disabled 55 56 [ErrorCondition] 57 bad-name-flag=disabled 58 59 \endcode 60 61 */ 62 63 include_once ( 'lib/ezutils/classes/ezdebug.php' ); 64 include_once ( 'lib/ezutils/classes/ezini.php' ); 65 66 class eZDebugSetting 67 { 68 /*! 69 Constructor 70 */ 71 function eZDebugSetting() 72 { 73 } 74 75 /*! 76 \static 77 \return true if the condition \a $conditionName is considered enabled. 78 */ 79 function isConditionTrue( $conditionName, $messageType ) 80 { 81 global $eZDebugSettingINIObject; 82 83 $ini =& $eZDebugSettingINIObject; 84 85 if ( isset( $eZDebugSettingINIObject ) and get_class( $ini ) == 'ezini' ) 86 { 87 if ( $ini->variable( 'DebugSettings', 'ConditionDebug' ) != 'enabled' ) 88 return false; 89 $generalSetting = 'GeneralCondition'; 90 $debugName = eZDebug::messageName( $messageType ); 91 $specificSetting = $debugName . 'Condition'; 92 if ( $ini->hasVariable( $generalSetting, $conditionName ) ) 93 return $ini->variable( $generalSetting, $conditionName ) == 'enabled'; 94 if ( $ini->hasVariable( $specificSetting, $conditionName ) ) 95 return $ini->variable( $specificSetting, $conditionName ) == 'enabled'; 96 } 97 return false; 98 } 99 100 /*! 101 \static 102 Creates a new debug label from the original and the condition and returns it. 103 */ 104 function changeLabel( $conditionName, $label ) 105 { 106 if ( $label == "" ) 107 return '<' . $conditionName . '>'; 108 else 109 return $label . ' <' . $conditionName . '>'; 110 } 111 112 /*! 113 \static 114 Writes a debug notice if the condition \a $conditionName is enabled. 115 */ 116 function writeNotice( $conditionName, $string, $label = "" ) 117 { 118 if ( !eZDebugSetting::isConditionTrue( $conditionName, EZ_LEVEL_NOTICE ) ) 119 return false; 120 eZDebug::writeNotice( $string, eZDebugSetting::changeLabel( $conditionName, $label ) ); 121 } 122 123 /*! 124 \static 125 Writes a debug warning if the condition \a $conditionName is enabled. 126 */ 127 function writeWarning( $conditionName, $string, $label = "" ) 128 { 129 if ( !eZDebugSetting::isConditionTrue( $conditionName, EZ_LEVEL_WARNING ) ) 130 return false; 131 eZDebug::writeWarning( $string, eZDebugSetting::changeLabel( $conditionName, $label ) ); 132 } 133 134 /*! 135 \static 136 Writes a debug error if the condition \a $conditionName is enabled. 137 */ 138 function writeError( $conditionName, $string, $label = "" ) 139 { 140 if ( !eZDebugSetting::isConditionTrue( $conditionName, EZ_LEVEL_ERROR ) ) 141 return false; 142 eZDebug::writeError( $string, eZDebugSetting::changeLabel( $conditionName, $label ) ); 143 } 144 145 /*! 146 \static 147 Writes a debug message if the condition \a $conditionName is enabled. 148 */ 149 function writeDebug( $conditionName, $string, $label = "" ) 150 { 151 if ( !eZDebugSetting::isConditionTrue( $conditionName, EZ_LEVEL_DEBUG ) ) 152 return false; 153 eZDebug::writeDebug( $string, eZDebugSetting::changeLabel( $conditionName, $label ) ); 154 } 155 156 /*! 157 \static 158 Adds the timing point if the condition \a $conditionName is enabled. 159 */ 160 function addTimingPoint( $conditionName, $label = "" ) 161 { 162 if ( !eZDebugSetting::isConditionTrue( $conditionName, EZ_LEVEL_TIMING_POINT ) ) 163 return false; 164 eZDebug::addTimingPoint( eZDebugSetting::changeLabel( $conditionName, $label ) ); 165 } 166 167 /*! 168 \static 169 Sets the INI object 170 */ 171 function setDebugINI( $ini ) 172 { 173 global $eZDebugSettingINIObject; 174 $eZDebugSettingINIObject = $ini; 175 } 176 177 } 178 179 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Sat Feb 24 10:30:04 2007 | par Balluche grâce à PHPXref 0.7 |