@@ -29,5 +29,5 @@ |
||
| 29 | 29 | * @subpackage pattern |
| 30 | 30 | */ |
| 31 | 31 | class Payone_Log4php_LoggerPatternConverterServer extends Payone_Log4php_LoggerPatternConverterSuperglobal { |
| 32 | - protected $name = '_SERVER'; |
|
| 32 | + protected $name = '_SERVER'; |
|
| 33 | 33 | } |
@@ -25,7 +25,7 @@ |
||
| 25 | 25 | * @subpackage pattern |
| 26 | 26 | */ |
| 27 | 27 | class Payone_Log4php_LoggerPatternConverterSessionID extends Payone_Log4php_LoggerPatternConverter { |
| 28 | - public function convert(Payone_Log4php_LoggerLoggingEvent $event) { |
|
| 29 | - return session_id(); |
|
| 30 | - } |
|
| 28 | + public function convert(Payone_Log4php_LoggerLoggingEvent $event) { |
|
| 29 | + return session_id(); |
|
| 30 | + } |
|
| 31 | 31 | } |
@@ -28,424 +28,424 @@ |
||
| 28 | 28 | */ |
| 29 | 29 | class Payone_Log4php_LoggerOptionConverter { |
| 30 | 30 | |
| 31 | - const DELIM_START = '${'; |
|
| 32 | - const DELIM_STOP = '}'; |
|
| 33 | - const DELIM_START_LEN = 2; |
|
| 34 | - const DELIM_STOP_LEN = 1; |
|
| 31 | + const DELIM_START = '${'; |
|
| 32 | + const DELIM_STOP = '}'; |
|
| 33 | + const DELIM_START_LEN = 2; |
|
| 34 | + const DELIM_STOP_LEN = 1; |
|
| 35 | 35 | |
| 36 | - /** String values which are converted to boolean TRUE. */ |
|
| 37 | - private static $trueValues = array('1', 'true', 'yes', 'on'); |
|
| 36 | + /** String values which are converted to boolean TRUE. */ |
|
| 37 | + private static $trueValues = array('1', 'true', 'yes', 'on'); |
|
| 38 | 38 | |
| 39 | - /** |
|
| 40 | - * String values which are converted to boolean FALSE. |
|
| 41 | - * |
|
| 42 | - * Note that an empty string must convert to false, because |
|
| 43 | - * parse_ini_file() which is used for parsing configuration |
|
| 44 | - * converts the value _false_ to an empty string. |
|
| 45 | - */ |
|
| 46 | - private static $falseValues = array('0', 'false', 'no', 'off', ''); |
|
| 39 | + /** |
|
| 40 | + * String values which are converted to boolean FALSE. |
|
| 41 | + * |
|
| 42 | + * Note that an empty string must convert to false, because |
|
| 43 | + * parse_ini_file() which is used for parsing configuration |
|
| 44 | + * converts the value _false_ to an empty string. |
|
| 45 | + */ |
|
| 46 | + private static $falseValues = array('0', 'false', 'no', 'off', ''); |
|
| 47 | 47 | |
| 48 | - /** |
|
| 49 | - * Read a predefined var. |
|
| 50 | - * |
|
| 51 | - * It returns a value referenced by <var>$key</var> using this search criteria: |
|
| 52 | - * - if <var>$key</var> is a constant then return it. Else |
|
| 53 | - * - if <var>$key</var> is set in <var>$_ENV</var> then return it. Else |
|
| 54 | - * - return <var>$def</var>. |
|
| 55 | - * |
|
| 56 | - * @param string $key The key to search for. |
|
| 57 | - * @param string $def The default value to return. |
|
| 58 | - * @return string the string value of the system property, or the default |
|
| 59 | - * value if there is no property with that key. |
|
| 60 | - */ |
|
| 61 | - public static function getSystemProperty($key, $def) { |
|
| 62 | - if(defined($key)) { |
|
| 63 | - return (string)constant($key); |
|
| 64 | - } else if(isset($_SERVER[$key])) { |
|
| 65 | - return (string)$_SERVER[$key]; |
|
| 66 | - } else if(isset($_ENV[$key])) { |
|
| 67 | - return (string)$_ENV[$key]; |
|
| 68 | - } else { |
|
| 69 | - return $def; |
|
| 70 | - } |
|
| 71 | - } |
|
| 48 | + /** |
|
| 49 | + * Read a predefined var. |
|
| 50 | + * |
|
| 51 | + * It returns a value referenced by <var>$key</var> using this search criteria: |
|
| 52 | + * - if <var>$key</var> is a constant then return it. Else |
|
| 53 | + * - if <var>$key</var> is set in <var>$_ENV</var> then return it. Else |
|
| 54 | + * - return <var>$def</var>. |
|
| 55 | + * |
|
| 56 | + * @param string $key The key to search for. |
|
| 57 | + * @param string $def The default value to return. |
|
| 58 | + * @return string the string value of the system property, or the default |
|
| 59 | + * value if there is no property with that key. |
|
| 60 | + */ |
|
| 61 | + public static function getSystemProperty($key, $def) { |
|
| 62 | + if(defined($key)) { |
|
| 63 | + return (string)constant($key); |
|
| 64 | + } else if(isset($_SERVER[$key])) { |
|
| 65 | + return (string)$_SERVER[$key]; |
|
| 66 | + } else if(isset($_ENV[$key])) { |
|
| 67 | + return (string)$_ENV[$key]; |
|
| 68 | + } else { |
|
| 69 | + return $def; |
|
| 70 | + } |
|
| 71 | + } |
|
| 72 | 72 | |
| 73 | - /** |
|
| 74 | - * If <var>$value</var> is <i>true</i>, then <i>true</i> is |
|
| 75 | - * returned. If <var>$value</var> is <i>false</i>, then |
|
| 76 | - * <i>true</i> is returned. Otherwise, <var>$default</var> is |
|
| 77 | - * returned. |
|
| 78 | - * |
|
| 79 | - * <p>Case of value is unimportant.</p> |
|
| 80 | - * |
|
| 81 | - * @param string $value |
|
| 82 | - * @param boolean $default |
|
| 83 | - * @return boolean |
|
| 84 | - */ |
|
| 85 | - public static function toBoolean($value, $default=true) { |
|
| 86 | - if (is_null($value)) { |
|
| 87 | - return $default; |
|
| 88 | - } elseif (is_string($value)) { |
|
| 89 | - $trimmedVal = strtolower(trim($value)); |
|
| 90 | - if("1" == $trimmedVal or "true" == $trimmedVal or "yes" == $trimmedVal or "on" == $trimmedVal) { |
|
| 91 | - return true; |
|
| 92 | - } else if ("" == $trimmedVal or "0" == $trimmedVal or "false" == $trimmedVal or "no" == $trimmedVal or "off" == $trimmedVal) { |
|
| 93 | - return false; |
|
| 94 | - } |
|
| 95 | - } elseif (is_bool($value)) { |
|
| 96 | - return $value; |
|
| 97 | - } elseif (is_int($value)) { |
|
| 98 | - return !($value == 0); // true is everything but 0 like in C |
|
| 99 | - } |
|
| 73 | + /** |
|
| 74 | + * If <var>$value</var> is <i>true</i>, then <i>true</i> is |
|
| 75 | + * returned. If <var>$value</var> is <i>false</i>, then |
|
| 76 | + * <i>true</i> is returned. Otherwise, <var>$default</var> is |
|
| 77 | + * returned. |
|
| 78 | + * |
|
| 79 | + * <p>Case of value is unimportant.</p> |
|
| 80 | + * |
|
| 81 | + * @param string $value |
|
| 82 | + * @param boolean $default |
|
| 83 | + * @return boolean |
|
| 84 | + */ |
|
| 85 | + public static function toBoolean($value, $default=true) { |
|
| 86 | + if (is_null($value)) { |
|
| 87 | + return $default; |
|
| 88 | + } elseif (is_string($value)) { |
|
| 89 | + $trimmedVal = strtolower(trim($value)); |
|
| 90 | + if("1" == $trimmedVal or "true" == $trimmedVal or "yes" == $trimmedVal or "on" == $trimmedVal) { |
|
| 91 | + return true; |
|
| 92 | + } else if ("" == $trimmedVal or "0" == $trimmedVal or "false" == $trimmedVal or "no" == $trimmedVal or "off" == $trimmedVal) { |
|
| 93 | + return false; |
|
| 94 | + } |
|
| 95 | + } elseif (is_bool($value)) { |
|
| 96 | + return $value; |
|
| 97 | + } elseif (is_int($value)) { |
|
| 98 | + return !($value == 0); // true is everything but 0 like in C |
|
| 99 | + } |
|
| 100 | 100 | |
| 101 | - return $default; |
|
| 102 | - } |
|
| 101 | + return $default; |
|
| 102 | + } |
|
| 103 | 103 | |
| 104 | - /** Converts $value to boolean, or throws an exception if not possible. */ |
|
| 105 | - public static function toBooleanEx($value) { |
|
| 106 | - if (isset($value)) { |
|
| 107 | - if (is_bool($value)) { |
|
| 108 | - return $value; |
|
| 109 | - } |
|
| 110 | - $value = strtolower(trim($value)); |
|
| 111 | - if (in_array($value, self::$trueValues)) { |
|
| 112 | - return true; |
|
| 113 | - } |
|
| 114 | - if (in_array($value, self::$falseValues)) { |
|
| 115 | - return false; |
|
| 116 | - } |
|
| 117 | - } |
|
| 104 | + /** Converts $value to boolean, or throws an exception if not possible. */ |
|
| 105 | + public static function toBooleanEx($value) { |
|
| 106 | + if (isset($value)) { |
|
| 107 | + if (is_bool($value)) { |
|
| 108 | + return $value; |
|
| 109 | + } |
|
| 110 | + $value = strtolower(trim($value)); |
|
| 111 | + if (in_array($value, self::$trueValues)) { |
|
| 112 | + return true; |
|
| 113 | + } |
|
| 114 | + if (in_array($value, self::$falseValues)) { |
|
| 115 | + return false; |
|
| 116 | + } |
|
| 117 | + } |
|
| 118 | 118 | |
| 119 | - throw new Payone_Log4php_LoggerException("Given value [" . var_export($value, true) . "] cannot be converted to boolean."); |
|
| 120 | - } |
|
| 119 | + throw new Payone_Log4php_LoggerException("Given value [" . var_export($value, true) . "] cannot be converted to boolean."); |
|
| 120 | + } |
|
| 121 | 121 | |
| 122 | - /** |
|
| 123 | - * @param string $value |
|
| 124 | - * @param integer $default |
|
| 125 | - * @return integer |
|
| 126 | - */ |
|
| 127 | - public static function toInt($value, $default) { |
|
| 128 | - $value = trim($value); |
|
| 129 | - if(is_numeric($value)) { |
|
| 130 | - return (int)$value; |
|
| 131 | - } else { |
|
| 132 | - return $default; |
|
| 133 | - } |
|
| 134 | - } |
|
| 122 | + /** |
|
| 123 | + * @param string $value |
|
| 124 | + * @param integer $default |
|
| 125 | + * @return integer |
|
| 126 | + */ |
|
| 127 | + public static function toInt($value, $default) { |
|
| 128 | + $value = trim($value); |
|
| 129 | + if(is_numeric($value)) { |
|
| 130 | + return (int)$value; |
|
| 131 | + } else { |
|
| 132 | + return $default; |
|
| 133 | + } |
|
| 134 | + } |
|
| 135 | 135 | |
| 136 | 136 | |
| 137 | - /** |
|
| 138 | - * Converts $value to integer, or throws an exception if not possible. |
|
| 139 | - * Floats cannot be converted to integer. |
|
| 140 | - */ |
|
| 141 | - public static function toIntegerEx($value) { |
|
| 142 | - if (is_integer($value)) { |
|
| 143 | - return $value; |
|
| 144 | - } |
|
| 145 | - if (is_numeric($value) && ($value == (integer) $value)) { |
|
| 146 | - return (integer) $value; |
|
| 147 | - } |
|
| 137 | + /** |
|
| 138 | + * Converts $value to integer, or throws an exception if not possible. |
|
| 139 | + * Floats cannot be converted to integer. |
|
| 140 | + */ |
|
| 141 | + public static function toIntegerEx($value) { |
|
| 142 | + if (is_integer($value)) { |
|
| 143 | + return $value; |
|
| 144 | + } |
|
| 145 | + if (is_numeric($value) && ($value == (integer) $value)) { |
|
| 146 | + return (integer) $value; |
|
| 147 | + } |
|
| 148 | 148 | |
| 149 | - throw new Payone_Log4php_LoggerException("Given value [" . var_export($value, true) . "] cannot be converted to integer."); |
|
| 150 | - } |
|
| 149 | + throw new Payone_Log4php_LoggerException("Given value [" . var_export($value, true) . "] cannot be converted to integer."); |
|
| 150 | + } |
|
| 151 | 151 | |
| 152 | - /** |
|
| 153 | - * Converts $value to integer, or throws an exception if not possible. |
|
| 154 | - * Floats cannot be converted to integer. |
|
| 155 | - */ |
|
| 156 | - public static function toPositiveIntegerEx($value) { |
|
| 157 | - if (is_integer($value) && $value > 0) { |
|
| 158 | - return $value; |
|
| 159 | - } |
|
| 160 | - if (is_numeric($value) && ($value == (integer) $value) && $value > 0) { |
|
| 161 | - return (integer) $value; |
|
| 162 | - } |
|
| 152 | + /** |
|
| 153 | + * Converts $value to integer, or throws an exception if not possible. |
|
| 154 | + * Floats cannot be converted to integer. |
|
| 155 | + */ |
|
| 156 | + public static function toPositiveIntegerEx($value) { |
|
| 157 | + if (is_integer($value) && $value > 0) { |
|
| 158 | + return $value; |
|
| 159 | + } |
|
| 160 | + if (is_numeric($value) && ($value == (integer) $value) && $value > 0) { |
|
| 161 | + return (integer) $value; |
|
| 162 | + } |
|
| 163 | 163 | |
| 164 | - throw new Payone_Log4php_LoggerException("Given value [" . var_export($value, true) . "] cannot be converted to a positive integer."); |
|
| 165 | - } |
|
| 164 | + throw new Payone_Log4php_LoggerException("Given value [" . var_export($value, true) . "] cannot be converted to a positive integer."); |
|
| 165 | + } |
|
| 166 | 166 | |
| 167 | - /** |
|
| 168 | - * Converts a standard or custom priority level to a Level |
|
| 169 | - * object. |
|
| 170 | - * |
|
| 171 | - * <p> If <var>$value</var> is of form "<b>level#full_file_classname</b>", |
|
| 172 | - * where <i>full_file_classname</i> means the class filename with path |
|
| 173 | - * but without php extension, then the specified class' <i>toLevel()</i> method |
|
| 174 | - * is called to process the specified level string; if no '#' |
|
| 175 | - * character is present, then the default {@link LoggerLevel} |
|
| 176 | - * class is used to process the level value.</p> |
|
| 177 | - * |
|
| 178 | - * <p>As a special case, if the <var>$value</var> parameter is |
|
| 179 | - * equal to the string "NULL", then the value <i>null</i> will |
|
| 180 | - * be returned.</p> |
|
| 181 | - * |
|
| 182 | - * <p>If any error occurs while converting the value to a level, |
|
| 183 | - * the <var>$defaultValue</var> parameter, which may be |
|
| 184 | - * <i>null</i>, is returned.</p> |
|
| 185 | - * |
|
| 186 | - * <p>Case of <var>$value</var> is insignificant for the level level, but is |
|
| 187 | - * significant for the class name part, if present.</p> |
|
| 188 | - * |
|
| 189 | - * @param string $value |
|
| 190 | - * @param Payone_Log4php_LoggerLevel $defaultValue |
|
| 191 | - * @return Payone_Log4php_LoggerLevel a {@link LoggerLevel} or null |
|
| 192 | - */ |
|
| 193 | - public static function toLevel($value, $defaultValue) { |
|
| 194 | - if($value === null) { |
|
| 195 | - return $defaultValue; |
|
| 196 | - } |
|
| 197 | - $hashIndex = strpos($value, '#'); |
|
| 198 | - if($hashIndex === false) { |
|
| 199 | - if("NULL" == strtoupper($value)) { |
|
| 200 | - return null; |
|
| 201 | - } else { |
|
| 202 | - // no class name specified : use standard Level class |
|
| 203 | - return Payone_Log4php_LoggerLevel::toLevel($value, $defaultValue); |
|
| 204 | - } |
|
| 205 | - } |
|
| 167 | + /** |
|
| 168 | + * Converts a standard or custom priority level to a Level |
|
| 169 | + * object. |
|
| 170 | + * |
|
| 171 | + * <p> If <var>$value</var> is of form "<b>level#full_file_classname</b>", |
|
| 172 | + * where <i>full_file_classname</i> means the class filename with path |
|
| 173 | + * but without php extension, then the specified class' <i>toLevel()</i> method |
|
| 174 | + * is called to process the specified level string; if no '#' |
|
| 175 | + * character is present, then the default {@link LoggerLevel} |
|
| 176 | + * class is used to process the level value.</p> |
|
| 177 | + * |
|
| 178 | + * <p>As a special case, if the <var>$value</var> parameter is |
|
| 179 | + * equal to the string "NULL", then the value <i>null</i> will |
|
| 180 | + * be returned.</p> |
|
| 181 | + * |
|
| 182 | + * <p>If any error occurs while converting the value to a level, |
|
| 183 | + * the <var>$defaultValue</var> parameter, which may be |
|
| 184 | + * <i>null</i>, is returned.</p> |
|
| 185 | + * |
|
| 186 | + * <p>Case of <var>$value</var> is insignificant for the level level, but is |
|
| 187 | + * significant for the class name part, if present.</p> |
|
| 188 | + * |
|
| 189 | + * @param string $value |
|
| 190 | + * @param Payone_Log4php_LoggerLevel $defaultValue |
|
| 191 | + * @return Payone_Log4php_LoggerLevel a {@link LoggerLevel} or null |
|
| 192 | + */ |
|
| 193 | + public static function toLevel($value, $defaultValue) { |
|
| 194 | + if($value === null) { |
|
| 195 | + return $defaultValue; |
|
| 196 | + } |
|
| 197 | + $hashIndex = strpos($value, '#'); |
|
| 198 | + if($hashIndex === false) { |
|
| 199 | + if("NULL" == strtoupper($value)) { |
|
| 200 | + return null; |
|
| 201 | + } else { |
|
| 202 | + // no class name specified : use standard Level class |
|
| 203 | + return Payone_Log4php_LoggerLevel::toLevel($value, $defaultValue); |
|
| 204 | + } |
|
| 205 | + } |
|
| 206 | 206 | |
| 207 | - $result = $defaultValue; |
|
| 207 | + $result = $defaultValue; |
|
| 208 | 208 | |
| 209 | - $clazz = substr($value, ($hashIndex + 1)); |
|
| 210 | - $levelName = substr($value, 0, $hashIndex); |
|
| 209 | + $clazz = substr($value, ($hashIndex + 1)); |
|
| 210 | + $levelName = substr($value, 0, $hashIndex); |
|
| 211 | 211 | |
| 212 | - // This is degenerate case but you never know. |
|
| 213 | - if("NULL" == strtoupper($levelName)) { |
|
| 214 | - return null; |
|
| 215 | - } |
|
| 212 | + // This is degenerate case but you never know. |
|
| 213 | + if("NULL" == strtoupper($levelName)) { |
|
| 214 | + return null; |
|
| 215 | + } |
|
| 216 | 216 | |
| 217 | - $clazz = basename($clazz); |
|
| 217 | + $clazz = basename($clazz); |
|
| 218 | 218 | |
| 219 | - if(class_exists($clazz)) { |
|
| 220 | - $result = @call_user_func(array($clazz, 'toLevel'), $levelName, $defaultValue); |
|
| 221 | - if(!$result instanceof Payone_Log4php_LoggerLevel) { |
|
| 222 | - $result = $defaultValue; |
|
| 223 | - } |
|
| 224 | - } |
|
| 225 | - return $result; |
|
| 226 | - } |
|
| 219 | + if(class_exists($clazz)) { |
|
| 220 | + $result = @call_user_func(array($clazz, 'toLevel'), $levelName, $defaultValue); |
|
| 221 | + if(!$result instanceof Payone_Log4php_LoggerLevel) { |
|
| 222 | + $result = $defaultValue; |
|
| 223 | + } |
|
| 224 | + } |
|
| 225 | + return $result; |
|
| 226 | + } |
|
| 227 | 227 | |
| 228 | 228 | |
| 229 | - /** Converts the value to a level. Throws an exception if not possible. */ |
|
| 230 | - public static function toLevelEx($value) { |
|
| 231 | - if ($value instanceof Payone_Log4php_LoggerLevel) { |
|
| 232 | - return $value; |
|
| 233 | - } |
|
| 234 | - $level = Payone_Log4php_LoggerLevel::toLevel($value); |
|
| 235 | - if ($level === null) { |
|
| 236 | - throw new Payone_Log4php_LoggerException("Given value [" . var_export($value, true) . "] cannot be converted to a logger level."); |
|
| 237 | - } |
|
| 238 | - return $level; |
|
| 239 | - } |
|
| 229 | + /** Converts the value to a level. Throws an exception if not possible. */ |
|
| 230 | + public static function toLevelEx($value) { |
|
| 231 | + if ($value instanceof Payone_Log4php_LoggerLevel) { |
|
| 232 | + return $value; |
|
| 233 | + } |
|
| 234 | + $level = Payone_Log4php_LoggerLevel::toLevel($value); |
|
| 235 | + if ($level === null) { |
|
| 236 | + throw new Payone_Log4php_LoggerException("Given value [" . var_export($value, true) . "] cannot be converted to a logger level."); |
|
| 237 | + } |
|
| 238 | + return $level; |
|
| 239 | + } |
|
| 240 | 240 | |
| 241 | - /** |
|
| 242 | - * @param string $value |
|
| 243 | - * @param float $default |
|
| 244 | - * @return float |
|
| 245 | - */ |
|
| 246 | - public static function toFileSize($value, $default) { |
|
| 247 | - if($value === null) { |
|
| 248 | - return $default; |
|
| 249 | - } |
|
| 241 | + /** |
|
| 242 | + * @param string $value |
|
| 243 | + * @param float $default |
|
| 244 | + * @return float |
|
| 245 | + */ |
|
| 246 | + public static function toFileSize($value, $default) { |
|
| 247 | + if($value === null) { |
|
| 248 | + return $default; |
|
| 249 | + } |
|
| 250 | 250 | |
| 251 | - $s = strtoupper(trim($value)); |
|
| 252 | - $multiplier = (float)1; |
|
| 253 | - if(($index = strpos($s, 'KB')) !== false) { |
|
| 254 | - $multiplier = 1024; |
|
| 255 | - $s = substr($s, 0, $index); |
|
| 256 | - } else if(($index = strpos($s, 'MB')) !== false) { |
|
| 257 | - $multiplier = 1024 * 1024; |
|
| 258 | - $s = substr($s, 0, $index); |
|
| 259 | - } else if(($index = strpos($s, 'GB')) !== false) { |
|
| 260 | - $multiplier = 1024 * 1024 * 1024; |
|
| 261 | - $s = substr($s, 0, $index); |
|
| 262 | - } |
|
| 263 | - if(is_numeric($s)) { |
|
| 264 | - return (float)$s * $multiplier; |
|
| 265 | - } |
|
| 266 | - return $default; |
|
| 267 | - } |
|
| 251 | + $s = strtoupper(trim($value)); |
|
| 252 | + $multiplier = (float)1; |
|
| 253 | + if(($index = strpos($s, 'KB')) !== false) { |
|
| 254 | + $multiplier = 1024; |
|
| 255 | + $s = substr($s, 0, $index); |
|
| 256 | + } else if(($index = strpos($s, 'MB')) !== false) { |
|
| 257 | + $multiplier = 1024 * 1024; |
|
| 258 | + $s = substr($s, 0, $index); |
|
| 259 | + } else if(($index = strpos($s, 'GB')) !== false) { |
|
| 260 | + $multiplier = 1024 * 1024 * 1024; |
|
| 261 | + $s = substr($s, 0, $index); |
|
| 262 | + } |
|
| 263 | + if(is_numeric($s)) { |
|
| 264 | + return (float)$s * $multiplier; |
|
| 265 | + } |
|
| 266 | + return $default; |
|
| 267 | + } |
|
| 268 | 268 | |
| 269 | 269 | |
| 270 | - /** |
|
| 271 | - * Converts a value to a valid file size (integer). |
|
| 272 | - * |
|
| 273 | - * Supports 'KB', 'MB' and 'GB' suffixes, where KB = 1024 B etc. |
|
| 274 | - * |
|
| 275 | - * The final value will be rounded to the nearest integer. |
|
| 276 | - * |
|
| 277 | - * Examples: |
|
| 278 | - * - '100' => 100 |
|
| 279 | - * - '100.12' => 100 |
|
| 280 | - * - '100KB' => 102400 |
|
| 281 | - * - '1.5MB' => 1572864 |
|
| 282 | - * |
|
| 283 | - * @param mixed $value File size (optionally with suffix). |
|
| 284 | - * @return integer Parsed file size. |
|
| 285 | - */ |
|
| 286 | - public static function toFileSizeEx($value) { |
|
| 270 | + /** |
|
| 271 | + * Converts a value to a valid file size (integer). |
|
| 272 | + * |
|
| 273 | + * Supports 'KB', 'MB' and 'GB' suffixes, where KB = 1024 B etc. |
|
| 274 | + * |
|
| 275 | + * The final value will be rounded to the nearest integer. |
|
| 276 | + * |
|
| 277 | + * Examples: |
|
| 278 | + * - '100' => 100 |
|
| 279 | + * - '100.12' => 100 |
|
| 280 | + * - '100KB' => 102400 |
|
| 281 | + * - '1.5MB' => 1572864 |
|
| 282 | + * |
|
| 283 | + * @param mixed $value File size (optionally with suffix). |
|
| 284 | + * @return integer Parsed file size. |
|
| 285 | + */ |
|
| 286 | + public static function toFileSizeEx($value) { |
|
| 287 | 287 | |
| 288 | - if (empty($value)) { |
|
| 289 | - throw new Payone_Log4php_LoggerException("Empty value cannot be converted to a file size."); |
|
| 290 | - } |
|
| 288 | + if (empty($value)) { |
|
| 289 | + throw new Payone_Log4php_LoggerException("Empty value cannot be converted to a file size."); |
|
| 290 | + } |
|
| 291 | 291 | |
| 292 | - if (is_numeric($value)) { |
|
| 293 | - return (integer) $value; |
|
| 294 | - } |
|
| 292 | + if (is_numeric($value)) { |
|
| 293 | + return (integer) $value; |
|
| 294 | + } |
|
| 295 | 295 | |
| 296 | - if (!is_string($value)) { |
|
| 297 | - throw new Payone_Log4php_LoggerException("Given value [" . var_export($value, true) . "] cannot be converted to a file size."); |
|
| 298 | - } |
|
| 296 | + if (!is_string($value)) { |
|
| 297 | + throw new Payone_Log4php_LoggerException("Given value [" . var_export($value, true) . "] cannot be converted to a file size."); |
|
| 298 | + } |
|
| 299 | 299 | |
| 300 | - $str = strtoupper(trim($value)); |
|
| 301 | - $count = preg_match('/^([0-9.]+)(KB|MB|GB)?$/', $str, $matches); |
|
| 300 | + $str = strtoupper(trim($value)); |
|
| 301 | + $count = preg_match('/^([0-9.]+)(KB|MB|GB)?$/', $str, $matches); |
|
| 302 | 302 | |
| 303 | - if ($count > 0) { |
|
| 304 | - $size = $matches[1]; |
|
| 305 | - $unit = $matches[2]; |
|
| 303 | + if ($count > 0) { |
|
| 304 | + $size = $matches[1]; |
|
| 305 | + $unit = $matches[2]; |
|
| 306 | 306 | |
| 307 | - switch($unit) { |
|
| 308 | - case 'KB': $size *= pow(1024, 1); break; |
|
| 309 | - case 'MB': $size *= pow(1024, 2); break; |
|
| 310 | - case 'GB': $size *= pow(1024, 3); break; |
|
| 311 | - } |
|
| 307 | + switch($unit) { |
|
| 308 | + case 'KB': $size *= pow(1024, 1); break; |
|
| 309 | + case 'MB': $size *= pow(1024, 2); break; |
|
| 310 | + case 'GB': $size *= pow(1024, 3); break; |
|
| 311 | + } |
|
| 312 | 312 | |
| 313 | - return (integer) $size; |
|
| 314 | - } |
|
| 313 | + return (integer) $size; |
|
| 314 | + } |
|
| 315 | 315 | |
| 316 | - throw new Payone_Log4php_LoggerException("Given value [$value] cannot be converted to a file size."); |
|
| 317 | - } |
|
| 316 | + throw new Payone_Log4php_LoggerException("Given value [$value] cannot be converted to a file size."); |
|
| 317 | + } |
|
| 318 | 318 | |
| 319 | - /** |
|
| 320 | - * Converts a value to string, or throws an exception if not possible. |
|
| 321 | - * |
|
| 322 | - * Objects can be converted to string if they implement the magic |
|
| 323 | - * __toString() method. |
|
| 324 | - * |
|
| 325 | - */ |
|
| 326 | - public static function toStringEx($value) { |
|
| 327 | - if (is_string($value)) { |
|
| 328 | - return $value; |
|
| 329 | - } |
|
| 330 | - if (is_numeric($value)) { |
|
| 331 | - return (string) $value; |
|
| 332 | - } |
|
| 333 | - if (is_object($value) && method_exists($value, '__toString')) { |
|
| 334 | - return (string) $value; |
|
| 335 | - } |
|
| 319 | + /** |
|
| 320 | + * Converts a value to string, or throws an exception if not possible. |
|
| 321 | + * |
|
| 322 | + * Objects can be converted to string if they implement the magic |
|
| 323 | + * __toString() method. |
|
| 324 | + * |
|
| 325 | + */ |
|
| 326 | + public static function toStringEx($value) { |
|
| 327 | + if (is_string($value)) { |
|
| 328 | + return $value; |
|
| 329 | + } |
|
| 330 | + if (is_numeric($value)) { |
|
| 331 | + return (string) $value; |
|
| 332 | + } |
|
| 333 | + if (is_object($value) && method_exists($value, '__toString')) { |
|
| 334 | + return (string) $value; |
|
| 335 | + } |
|
| 336 | 336 | |
| 337 | - throw new Payone_Log4php_LoggerException("Given value [" . var_export($value, true) . "] cannot be converted to string."); |
|
| 338 | - } |
|
| 337 | + throw new Payone_Log4php_LoggerException("Given value [" . var_export($value, true) . "] cannot be converted to string."); |
|
| 338 | + } |
|
| 339 | 339 | |
| 340 | 340 | |
| 341 | - /** |
|
| 342 | - * Find the value corresponding to <var>$key</var> in |
|
| 343 | - * <var>$props</var>. Then perform variable substitution on the |
|
| 344 | - * found value. |
|
| 345 | - * |
|
| 346 | - * @param string $key |
|
| 347 | - * @param array $props |
|
| 348 | - * @return string |
|
| 349 | - */ |
|
| 350 | - public static function findAndSubst($key, $props) { |
|
| 351 | - $value = @$props[$key]; |
|
| 341 | + /** |
|
| 342 | + * Find the value corresponding to <var>$key</var> in |
|
| 343 | + * <var>$props</var>. Then perform variable substitution on the |
|
| 344 | + * found value. |
|
| 345 | + * |
|
| 346 | + * @param string $key |
|
| 347 | + * @param array $props |
|
| 348 | + * @return string |
|
| 349 | + */ |
|
| 350 | + public static function findAndSubst($key, $props) { |
|
| 351 | + $value = @$props[$key]; |
|
| 352 | 352 | |
| 353 | - // If coming from the LoggerConfiguratorIni, some options were |
|
| 354 | - // already mangled by parse_ini_file: |
|
| 355 | - // |
|
| 356 | - // not specified => never reaches this code |
|
| 357 | - // ""|off|false|null => string(0) "" |
|
| 358 | - // "1"|on|true => string(1) "1" |
|
| 359 | - // "true" => string(4) "true" |
|
| 360 | - // "false" => string(5) "false" |
|
| 361 | - // |
|
| 362 | - // As the integer 1 and the boolean true are therefore indistinguable |
|
| 363 | - // it's up to the setter how to deal with it, they can not be cast |
|
| 364 | - // into a boolean here. {@see toBoolean} |
|
| 365 | - // Even an empty value has to be given to the setter as it has been |
|
| 366 | - // explicitly set by the user and is different from an option which |
|
| 367 | - // has not been specified and therefore keeps its default value. |
|
| 368 | - // |
|
| 369 | - // if(!empty($value)) { |
|
| 370 | - return Payone_Log4php_LoggerOptionConverter::substVars($value, $props); |
|
| 371 | - // } |
|
| 372 | - } |
|
| 353 | + // If coming from the LoggerConfiguratorIni, some options were |
|
| 354 | + // already mangled by parse_ini_file: |
|
| 355 | + // |
|
| 356 | + // not specified => never reaches this code |
|
| 357 | + // ""|off|false|null => string(0) "" |
|
| 358 | + // "1"|on|true => string(1) "1" |
|
| 359 | + // "true" => string(4) "true" |
|
| 360 | + // "false" => string(5) "false" |
|
| 361 | + // |
|
| 362 | + // As the integer 1 and the boolean true are therefore indistinguable |
|
| 363 | + // it's up to the setter how to deal with it, they can not be cast |
|
| 364 | + // into a boolean here. {@see toBoolean} |
|
| 365 | + // Even an empty value has to be given to the setter as it has been |
|
| 366 | + // explicitly set by the user and is different from an option which |
|
| 367 | + // has not been specified and therefore keeps its default value. |
|
| 368 | + // |
|
| 369 | + // if(!empty($value)) { |
|
| 370 | + return Payone_Log4php_LoggerOptionConverter::substVars($value, $props); |
|
| 371 | + // } |
|
| 372 | + } |
|
| 373 | 373 | |
| 374 | - /** |
|
| 375 | - * Perform variable substitution in string <var>$val</var> from the |
|
| 376 | - * values of keys found with the {@link getSystemProperty()} method. |
|
| 377 | - * |
|
| 378 | - * <p>The variable substitution delimeters are <b>${</b> and <b>}</b>. |
|
| 379 | - * |
|
| 380 | - * <p>For example, if the "MY_CONSTANT" contains "value", then |
|
| 381 | - * the call |
|
| 382 | - * <code> |
|
| 383 | - * $s = LoggerOptionConverter::substVars("Value of key is ${MY_CONSTANT}."); |
|
| 384 | - * </code> |
|
| 385 | - * will set the variable <i>$s</i> to "Value of key is value.".</p> |
|
| 386 | - * |
|
| 387 | - * <p>If no value could be found for the specified key, then the |
|
| 388 | - * <var>$props</var> parameter is searched, if the value could not |
|
| 389 | - * be found there, then substitution defaults to the empty string.</p> |
|
| 390 | - * |
|
| 391 | - * <p>For example, if {@link getSystemProperty()} cannot find any value for the key |
|
| 392 | - * "inexistentKey", then the call |
|
| 393 | - * <code> |
|
| 394 | - * $s = LoggerOptionConverter::substVars("Value of inexistentKey is [${inexistentKey}]"); |
|
| 395 | - * </code> |
|
| 396 | - * will set <var>$s</var> to "Value of inexistentKey is []".</p> |
|
| 397 | - * |
|
| 398 | - * <p>A warn is thrown if <var>$val</var> contains a start delimeter "${" |
|
| 399 | - * which is not balanced by a stop delimeter "}" and an empty string is returned.</p> |
|
| 400 | - * |
|
| 401 | - * @param string $val The string on which variable substitution is performed. |
|
| 402 | - * @param array $props |
|
| 403 | - * @return string |
|
| 404 | - */ |
|
| 405 | - // TODO: this method doesn't work correctly with key = true, it needs key = "true" which is odd |
|
| 406 | - public static function substVars($val, $props = null) { |
|
| 407 | - $sbuf = ''; |
|
| 408 | - $i = 0; |
|
| 409 | - while(true) { |
|
| 410 | - $j = strpos($val, self::DELIM_START, $i); |
|
| 411 | - if($j === false) { |
|
| 412 | - // no more variables |
|
| 413 | - if($i == 0) { // this is a simple string |
|
| 414 | - return $val; |
|
| 415 | - } else { // add the tail string which contails no variables and return the result. |
|
| 416 | - $sbuf .= substr($val, $i); |
|
| 417 | - return $sbuf; |
|
| 418 | - } |
|
| 419 | - } else { |
|
| 374 | + /** |
|
| 375 | + * Perform variable substitution in string <var>$val</var> from the |
|
| 376 | + * values of keys found with the {@link getSystemProperty()} method. |
|
| 377 | + * |
|
| 378 | + * <p>The variable substitution delimeters are <b>${</b> and <b>}</b>. |
|
| 379 | + * |
|
| 380 | + * <p>For example, if the "MY_CONSTANT" contains "value", then |
|
| 381 | + * the call |
|
| 382 | + * <code> |
|
| 383 | + * $s = LoggerOptionConverter::substVars("Value of key is ${MY_CONSTANT}."); |
|
| 384 | + * </code> |
|
| 385 | + * will set the variable <i>$s</i> to "Value of key is value.".</p> |
|
| 386 | + * |
|
| 387 | + * <p>If no value could be found for the specified key, then the |
|
| 388 | + * <var>$props</var> parameter is searched, if the value could not |
|
| 389 | + * be found there, then substitution defaults to the empty string.</p> |
|
| 390 | + * |
|
| 391 | + * <p>For example, if {@link getSystemProperty()} cannot find any value for the key |
|
| 392 | + * "inexistentKey", then the call |
|
| 393 | + * <code> |
|
| 394 | + * $s = LoggerOptionConverter::substVars("Value of inexistentKey is [${inexistentKey}]"); |
|
| 395 | + * </code> |
|
| 396 | + * will set <var>$s</var> to "Value of inexistentKey is []".</p> |
|
| 397 | + * |
|
| 398 | + * <p>A warn is thrown if <var>$val</var> contains a start delimeter "${" |
|
| 399 | + * which is not balanced by a stop delimeter "}" and an empty string is returned.</p> |
|
| 400 | + * |
|
| 401 | + * @param string $val The string on which variable substitution is performed. |
|
| 402 | + * @param array $props |
|
| 403 | + * @return string |
|
| 404 | + */ |
|
| 405 | + // TODO: this method doesn't work correctly with key = true, it needs key = "true" which is odd |
|
| 406 | + public static function substVars($val, $props = null) { |
|
| 407 | + $sbuf = ''; |
|
| 408 | + $i = 0; |
|
| 409 | + while(true) { |
|
| 410 | + $j = strpos($val, self::DELIM_START, $i); |
|
| 411 | + if($j === false) { |
|
| 412 | + // no more variables |
|
| 413 | + if($i == 0) { // this is a simple string |
|
| 414 | + return $val; |
|
| 415 | + } else { // add the tail string which contails no variables and return the result. |
|
| 416 | + $sbuf .= substr($val, $i); |
|
| 417 | + return $sbuf; |
|
| 418 | + } |
|
| 419 | + } else { |
|
| 420 | 420 | |
| 421 | - $sbuf .= substr($val, $i, $j-$i); |
|
| 422 | - $k = strpos($val, self::DELIM_STOP, $j); |
|
| 423 | - if($k === false) { |
|
| 424 | - // LoggerOptionConverter::substVars() has no closing brace. Opening brace |
|
| 425 | - return ''; |
|
| 426 | - } else { |
|
| 427 | - $j += self::DELIM_START_LEN; |
|
| 428 | - $key = substr($val, $j, $k - $j); |
|
| 429 | - // first try in System properties |
|
| 430 | - $replacement = Payone_Log4php_LoggerOptionConverter::getSystemProperty($key, null); |
|
| 431 | - // then try props parameter |
|
| 432 | - if($replacement == null and $props !== null) { |
|
| 433 | - $replacement = @$props[$key]; |
|
| 434 | - } |
|
| 421 | + $sbuf .= substr($val, $i, $j-$i); |
|
| 422 | + $k = strpos($val, self::DELIM_STOP, $j); |
|
| 423 | + if($k === false) { |
|
| 424 | + // LoggerOptionConverter::substVars() has no closing brace. Opening brace |
|
| 425 | + return ''; |
|
| 426 | + } else { |
|
| 427 | + $j += self::DELIM_START_LEN; |
|
| 428 | + $key = substr($val, $j, $k - $j); |
|
| 429 | + // first try in System properties |
|
| 430 | + $replacement = Payone_Log4php_LoggerOptionConverter::getSystemProperty($key, null); |
|
| 431 | + // then try props parameter |
|
| 432 | + if($replacement == null and $props !== null) { |
|
| 433 | + $replacement = @$props[$key]; |
|
| 434 | + } |
|
| 435 | 435 | |
| 436 | - if(!empty($replacement)) { |
|
| 437 | - // Do variable substitution on the replacement string |
|
| 438 | - // such that we can solve "Hello ${x2}" as "Hello p1" |
|
| 439 | - // the where the properties are |
|
| 440 | - // x1=p1 |
|
| 441 | - // x2=${x1} |
|
| 442 | - $recursiveReplacement = Payone_Log4php_LoggerOptionConverter::substVars($replacement, $props); |
|
| 443 | - $sbuf .= $recursiveReplacement; |
|
| 444 | - } |
|
| 445 | - $i = $k + self::DELIM_STOP_LEN; |
|
| 446 | - } |
|
| 447 | - } |
|
| 448 | - } |
|
| 449 | - } |
|
| 436 | + if(!empty($replacement)) { |
|
| 437 | + // Do variable substitution on the replacement string |
|
| 438 | + // such that we can solve "Hello ${x2}" as "Hello p1" |
|
| 439 | + // the where the properties are |
|
| 440 | + // x1=p1 |
|
| 441 | + // x2=${x1} |
|
| 442 | + $recursiveReplacement = Payone_Log4php_LoggerOptionConverter::substVars($replacement, $props); |
|
| 443 | + $sbuf .= $recursiveReplacement; |
|
| 444 | + } |
|
| 445 | + $i = $k + self::DELIM_STOP_LEN; |
|
| 446 | + } |
|
| 447 | + } |
|
| 448 | + } |
|
| 449 | + } |
|
| 450 | 450 | |
| 451 | 451 | } |
@@ -28,41 +28,41 @@ |
||
| 28 | 28 | */ |
| 29 | 29 | class Payone_Log4php_LoggerPatternConverterThrowable extends Payone_Log4php_LoggerPatternConverter { |
| 30 | 30 | |
| 31 | - private $depth; |
|
| 31 | + private $depth; |
|
| 32 | 32 | |
| 33 | - public function activateOptions() { |
|
| 34 | - if (isset($this->option) && is_numeric($op) && $op >= 0) { |
|
| 35 | - $this->depth = (integer) $this->option; |
|
| 36 | - } |
|
| 37 | - } |
|
| 33 | + public function activateOptions() { |
|
| 34 | + if (isset($this->option) && is_numeric($op) && $op >= 0) { |
|
| 35 | + $this->depth = (integer) $this->option; |
|
| 36 | + } |
|
| 37 | + } |
|
| 38 | 38 | |
| 39 | - public function convert(Payone_Log4php_LoggerLoggingEvent $event) { |
|
| 39 | + public function convert(Payone_Log4php_LoggerLoggingEvent $event) { |
|
| 40 | 40 | |
| 41 | - $info = $event->getThrowableInformation(); |
|
| 42 | - if ($info === null) { |
|
| 43 | - return ''; |
|
| 44 | - } |
|
| 41 | + $info = $event->getThrowableInformation(); |
|
| 42 | + if ($info === null) { |
|
| 43 | + return ''; |
|
| 44 | + } |
|
| 45 | 45 | |
| 46 | - $ex = $info->getThrowable(); |
|
| 46 | + $ex = $info->getThrowable(); |
|
| 47 | 47 | |
| 48 | - // Format exception to string |
|
| 49 | - $strEx = get_class($ex) . ': "' . $ex->getMessage() . '"' . PHP_EOL; |
|
| 50 | - $strEx .= 'at '. $ex->getFile() . ':' . $ex->getLine(); |
|
| 48 | + // Format exception to string |
|
| 49 | + $strEx = get_class($ex) . ': "' . $ex->getMessage() . '"' . PHP_EOL; |
|
| 50 | + $strEx .= 'at '. $ex->getFile() . ':' . $ex->getLine(); |
|
| 51 | 51 | |
| 52 | - // Add trace if required |
|
| 53 | - if ($this->depth === null || $this->depth > 0) { |
|
| 54 | - $trace = $ex->getTrace(); |
|
| 55 | - foreach($trace as $key => $item) { |
|
| 56 | - if (isset($this->depth) && $key > $this->depth) { |
|
| 57 | - break; |
|
| 58 | - } |
|
| 59 | - $strEx .= PHP_EOL . "#$key " . |
|
| 60 | - "{$item['file']}:{$item['line']} " . |
|
| 61 | - "in {$item['class']}{$item['type']}{$item['function']}()"; |
|
| 62 | - } |
|
| 63 | - } |
|
| 52 | + // Add trace if required |
|
| 53 | + if ($this->depth === null || $this->depth > 0) { |
|
| 54 | + $trace = $ex->getTrace(); |
|
| 55 | + foreach($trace as $key => $item) { |
|
| 56 | + if (isset($this->depth) && $key > $this->depth) { |
|
| 57 | + break; |
|
| 58 | + } |
|
| 59 | + $strEx .= PHP_EOL . "#$key " . |
|
| 60 | + "{$item['file']}:{$item['line']} " . |
|
| 61 | + "in {$item['class']}{$item['type']}{$item['function']}()"; |
|
| 62 | + } |
|
| 63 | + } |
|
| 64 | 64 | |
| 65 | - return $strEx; |
|
| 66 | - } |
|
| 65 | + return $strEx; |
|
| 66 | + } |
|
| 67 | 67 | } |
| 68 | - |
|
| 69 | 68 | \ No newline at end of file |
| 69 | + |
|
| 70 | 70 | \ No newline at end of file |
@@ -27,97 +27,97 @@ |
||
| 27 | 27 | */ |
| 28 | 28 | class Payone_Log4php_LoggerUtils { |
| 29 | 29 | |
| 30 | - /** |
|
| 31 | - * Splits a fully qualified class name into fragments delimited by the |
|
| 32 | - * namespace separator (\). |
|
| 33 | - * |
|
| 34 | - * For backward compatibility, a dot (.) can be used as a delimiter as |
|
| 35 | - * well. |
|
| 36 | - * |
|
| 37 | - * @param string $name |
|
| 38 | - * |
|
| 39 | - * @return array Class name split into fragments. |
|
| 40 | - */ |
|
| 41 | - public static function tokenizeClassName($name) { |
|
| 42 | - $name = str_replace('.', '\\', $name); |
|
| 43 | - $name = trim($name, ' \\'); |
|
| 44 | - $fragments = explode('\\', $name); |
|
| 30 | + /** |
|
| 31 | + * Splits a fully qualified class name into fragments delimited by the |
|
| 32 | + * namespace separator (\). |
|
| 33 | + * |
|
| 34 | + * For backward compatibility, a dot (.) can be used as a delimiter as |
|
| 35 | + * well. |
|
| 36 | + * |
|
| 37 | + * @param string $name |
|
| 38 | + * |
|
| 39 | + * @return array Class name split into fragments. |
|
| 40 | + */ |
|
| 41 | + public static function tokenizeClassName($name) { |
|
| 42 | + $name = str_replace('.', '\\', $name); |
|
| 43 | + $name = trim($name, ' \\'); |
|
| 44 | + $fragments = explode('\\', $name); |
|
| 45 | 45 | |
| 46 | - foreach($fragments as $key => $fragment) { |
|
| 47 | - if (trim($fragment) === '') { |
|
| 48 | - unset($fragments[$key]); |
|
| 49 | - } |
|
| 50 | - } |
|
| 46 | + foreach($fragments as $key => $fragment) { |
|
| 47 | + if (trim($fragment) === '') { |
|
| 48 | + unset($fragments[$key]); |
|
| 49 | + } |
|
| 50 | + } |
|
| 51 | 51 | |
| 52 | - return $fragments; |
|
| 53 | - } |
|
| 52 | + return $fragments; |
|
| 53 | + } |
|
| 54 | 54 | |
| 55 | - /** |
|
| 56 | - * Attempts to shorten the given class name to the desired length. |
|
| 57 | - * |
|
| 58 | - * This is done by separating the class name into fragments (delimited |
|
| 59 | - * by \ or .) and trimming individual fragments, starting with the left, |
|
| 60 | - * until desired length has been reached. |
|
| 61 | - * |
|
| 62 | - * The final fragment (i.e. class name) will never be shortened so the |
|
| 63 | - * result may still be longer than given length. |
|
| 64 | - * |
|
| 65 | - * @param string $name The (qualified) class name. |
|
| 66 | - * @param integer $length The length to shorten to. If null or 0 is given, |
|
| 67 | - * the name will be returned without shortening. |
|
| 68 | - */ |
|
| 69 | - public static function shortenClassName($name, $length) { |
|
| 70 | - if ($length === null || $length < 0) { |
|
| 71 | - return $name; |
|
| 72 | - } |
|
| 55 | + /** |
|
| 56 | + * Attempts to shorten the given class name to the desired length. |
|
| 57 | + * |
|
| 58 | + * This is done by separating the class name into fragments (delimited |
|
| 59 | + * by \ or .) and trimming individual fragments, starting with the left, |
|
| 60 | + * until desired length has been reached. |
|
| 61 | + * |
|
| 62 | + * The final fragment (i.e. class name) will never be shortened so the |
|
| 63 | + * result may still be longer than given length. |
|
| 64 | + * |
|
| 65 | + * @param string $name The (qualified) class name. |
|
| 66 | + * @param integer $length The length to shorten to. If null or 0 is given, |
|
| 67 | + * the name will be returned without shortening. |
|
| 68 | + */ |
|
| 69 | + public static function shortenClassName($name, $length) { |
|
| 70 | + if ($length === null || $length < 0) { |
|
| 71 | + return $name; |
|
| 72 | + } |
|
| 73 | 73 | |
| 74 | - $name = str_replace('.', '\\', $name); |
|
| 75 | - $name = trim($name, ' \\'); |
|
| 74 | + $name = str_replace('.', '\\', $name); |
|
| 75 | + $name = trim($name, ' \\'); |
|
| 76 | 76 | |
| 77 | - // Check if any shortening is required |
|
| 78 | - $currentLength = strlen($name); |
|
| 79 | - if ($currentLength <= $length) { |
|
| 80 | - return $name; |
|
| 81 | - } |
|
| 77 | + // Check if any shortening is required |
|
| 78 | + $currentLength = strlen($name); |
|
| 79 | + if ($currentLength <= $length) { |
|
| 80 | + return $name; |
|
| 81 | + } |
|
| 82 | 82 | |
| 83 | - // Split name into fragments |
|
| 84 | - $fragments = explode('\\', $name); |
|
| 83 | + // Split name into fragments |
|
| 84 | + $fragments = explode('\\', $name); |
|
| 85 | 85 | |
| 86 | - // If zero length is specified, return only last fragment |
|
| 87 | - if ($length == 0) { |
|
| 88 | - return array_pop($fragments); |
|
| 89 | - } |
|
| 86 | + // If zero length is specified, return only last fragment |
|
| 87 | + if ($length == 0) { |
|
| 88 | + return array_pop($fragments); |
|
| 89 | + } |
|
| 90 | 90 | |
| 91 | - // If the name splits to only one fragment, then it cannot be shortened |
|
| 92 | - $count = count($fragments); |
|
| 93 | - if ($count == 1) { |
|
| 94 | - return $name; |
|
| 95 | - } |
|
| 91 | + // If the name splits to only one fragment, then it cannot be shortened |
|
| 92 | + $count = count($fragments); |
|
| 93 | + if ($count == 1) { |
|
| 94 | + return $name; |
|
| 95 | + } |
|
| 96 | 96 | |
| 97 | - foreach($fragments as $key => &$fragment) { |
|
| 97 | + foreach($fragments as $key => &$fragment) { |
|
| 98 | 98 | |
| 99 | - // Never shorten last fragment |
|
| 100 | - if ($key == $count - 1) { |
|
| 101 | - break; |
|
| 102 | - } |
|
| 99 | + // Never shorten last fragment |
|
| 100 | + if ($key == $count - 1) { |
|
| 101 | + break; |
|
| 102 | + } |
|
| 103 | 103 | |
| 104 | - // Check for empty fragments (shouldn't happen but it's possible) |
|
| 105 | - $fragLen = strlen($fragment); |
|
| 106 | - if ($fragLen <= 1) { |
|
| 107 | - continue; |
|
| 108 | - } |
|
| 104 | + // Check for empty fragments (shouldn't happen but it's possible) |
|
| 105 | + $fragLen = strlen($fragment); |
|
| 106 | + if ($fragLen <= 1) { |
|
| 107 | + continue; |
|
| 108 | + } |
|
| 109 | 109 | |
| 110 | - // Shorten fragment to one character and check if total length satisfactory |
|
| 111 | - $fragment = substr($fragment, 0, 1); |
|
| 112 | - $currentLength = $currentLength - $fragLen + 1; |
|
| 110 | + // Shorten fragment to one character and check if total length satisfactory |
|
| 111 | + $fragment = substr($fragment, 0, 1); |
|
| 112 | + $currentLength = $currentLength - $fragLen + 1; |
|
| 113 | 113 | |
| 114 | - if ($currentLength <= $length) { |
|
| 115 | - break; |
|
| 116 | - } |
|
| 117 | - } |
|
| 118 | - unset($fragment); |
|
| 114 | + if ($currentLength <= $length) { |
|
| 115 | + break; |
|
| 116 | + } |
|
| 117 | + } |
|
| 118 | + unset($fragment); |
|
| 119 | 119 | |
| 120 | - return implode('\\', $fragments); |
|
| 121 | - } |
|
| 120 | + return implode('\\', $fragments); |
|
| 121 | + } |
|
| 122 | 122 | } |
| 123 | 123 | |
@@ -43,63 +43,63 @@ |
||
| 43 | 43 | */ |
| 44 | 44 | class Payone_Log4php_LoggerAppenderConsole extends Payone_Log4php_LoggerAppender { |
| 45 | 45 | |
| 46 | - const STDOUT = 'php://stdout'; |
|
| 47 | - const STDERR = 'php://stderr'; |
|
| 46 | + const STDOUT = 'php://stdout'; |
|
| 47 | + const STDERR = 'php://stderr'; |
|
| 48 | 48 | |
| 49 | - /** |
|
| 50 | - * Can be 'php://stdout' or 'php://stderr'. But it's better to use keywords <b>STDOUT</b> and <b>STDERR</b> (case insensitive). |
|
| 51 | - * Default is STDOUT |
|
| 52 | - * @var string |
|
| 53 | - */ |
|
| 54 | - protected $target = self::STDOUT; |
|
| 49 | + /** |
|
| 50 | + * Can be 'php://stdout' or 'php://stderr'. But it's better to use keywords <b>STDOUT</b> and <b>STDERR</b> (case insensitive). |
|
| 51 | + * Default is STDOUT |
|
| 52 | + * @var string |
|
| 53 | + */ |
|
| 54 | + protected $target = self::STDOUT; |
|
| 55 | 55 | |
| 56 | - /** |
|
| 57 | - * @var mixed the resource used to open stdout/stderr |
|
| 58 | - */ |
|
| 59 | - protected $fp = null; |
|
| 56 | + /** |
|
| 57 | + * @var mixed the resource used to open stdout/stderr |
|
| 58 | + */ |
|
| 59 | + protected $fp = null; |
|
| 60 | 60 | |
| 61 | - /** |
|
| 62 | - * Set console target. |
|
| 63 | - * @param mixed $value a constant or a string |
|
| 64 | - */ |
|
| 65 | - public function setTarget($value) { |
|
| 66 | - $v = trim($value); |
|
| 67 | - if ($v == self::STDOUT || strtoupper($v) == 'STDOUT') { |
|
| 68 | - $this->target = self::STDOUT; |
|
| 69 | - } elseif ($v == self::STDERR || strtoupper($v) == 'STDERR') { |
|
| 70 | - $this->target = self::STDERR; |
|
| 71 | - } else { |
|
| 72 | - $value = var_export($value); |
|
| 73 | - $this->warn("Invalid value given for 'target' property: [$value]. Property not set."); |
|
| 74 | - } |
|
| 75 | - } |
|
| 61 | + /** |
|
| 62 | + * Set console target. |
|
| 63 | + * @param mixed $value a constant or a string |
|
| 64 | + */ |
|
| 65 | + public function setTarget($value) { |
|
| 66 | + $v = trim($value); |
|
| 67 | + if ($v == self::STDOUT || strtoupper($v) == 'STDOUT') { |
|
| 68 | + $this->target = self::STDOUT; |
|
| 69 | + } elseif ($v == self::STDERR || strtoupper($v) == 'STDERR') { |
|
| 70 | + $this->target = self::STDERR; |
|
| 71 | + } else { |
|
| 72 | + $value = var_export($value); |
|
| 73 | + $this->warn("Invalid value given for 'target' property: [$value]. Property not set."); |
|
| 74 | + } |
|
| 75 | + } |
|
| 76 | 76 | |
| 77 | - public function getTarget() { |
|
| 78 | - return $this->target; |
|
| 79 | - } |
|
| 77 | + public function getTarget() { |
|
| 78 | + return $this->target; |
|
| 79 | + } |
|
| 80 | 80 | |
| 81 | - public function activateOptions() { |
|
| 82 | - $this->fp = fopen($this->target, 'w'); |
|
| 83 | - if(is_resource($this->fp) && $this->layout !== null) { |
|
| 84 | - fwrite($this->fp, $this->layout->getHeader()); |
|
| 85 | - } |
|
| 86 | - $this->closed = (bool)is_resource($this->fp) === false; |
|
| 87 | - } |
|
| 81 | + public function activateOptions() { |
|
| 82 | + $this->fp = fopen($this->target, 'w'); |
|
| 83 | + if(is_resource($this->fp) && $this->layout !== null) { |
|
| 84 | + fwrite($this->fp, $this->layout->getHeader()); |
|
| 85 | + } |
|
| 86 | + $this->closed = (bool)is_resource($this->fp) === false; |
|
| 87 | + } |
|
| 88 | 88 | |
| 89 | - public function close() { |
|
| 90 | - if($this->closed != true) { |
|
| 91 | - if (is_resource($this->fp) && $this->layout !== null) { |
|
| 92 | - fwrite($this->fp, $this->layout->getFooter()); |
|
| 93 | - fclose($this->fp); |
|
| 94 | - } |
|
| 95 | - $this->closed = true; |
|
| 96 | - } |
|
| 97 | - } |
|
| 89 | + public function close() { |
|
| 90 | + if($this->closed != true) { |
|
| 91 | + if (is_resource($this->fp) && $this->layout !== null) { |
|
| 92 | + fwrite($this->fp, $this->layout->getFooter()); |
|
| 93 | + fclose($this->fp); |
|
| 94 | + } |
|
| 95 | + $this->closed = true; |
|
| 96 | + } |
|
| 97 | + } |
|
| 98 | 98 | |
| 99 | - public function append(Payone_Log4php_LoggerLoggingEvent $event) { |
|
| 100 | - if (is_resource($this->fp) && $this->layout !== null) { |
|
| 101 | - fwrite($this->fp, $this->layout->format($event)); |
|
| 102 | - } |
|
| 103 | - } |
|
| 99 | + public function append(Payone_Log4php_LoggerLoggingEvent $event) { |
|
| 100 | + if (is_resource($this->fp) && $this->layout !== null) { |
|
| 101 | + fwrite($this->fp, $this->layout->format($event)); |
|
| 102 | + } |
|
| 103 | + } |
|
| 104 | 104 | } |
| 105 | 105 | |
@@ -48,184 +48,184 @@ |
||
| 48 | 48 | */ |
| 49 | 49 | class Payone_Log4php_LoggerAppenderRollingFile extends Payone_Log4php_LoggerAppenderFile { |
| 50 | 50 | |
| 51 | - /** |
|
| 52 | - * Set the maximum size that the output file is allowed to reach |
|
| 53 | - * before being rolled over to backup files. |
|
| 54 | - * |
|
| 55 | - * <p>In configuration files, the <var>MaxFileSize</var> option takes a |
|
| 56 | - * long integer in the range 0 - 2^63. You can specify the value |
|
| 57 | - * with the suffixes "KB", "MB" or "GB" so that the integer is |
|
| 58 | - * interpreted being expressed respectively in kilobytes, megabytes |
|
| 59 | - * or gigabytes. For example, the value "10KB" will be interpreted |
|
| 60 | - * as 10240.</p> |
|
| 61 | - * <p>The default maximum file size is 10MB.</p> |
|
| 62 | - * |
|
| 63 | - * <p>Note that MaxFileSize cannot exceed <b>2 GB</b>.</p> |
|
| 64 | - * |
|
| 65 | - * @var integer |
|
| 66 | - */ |
|
| 67 | - protected $maxFileSize = 10485760; |
|
| 51 | + /** |
|
| 52 | + * Set the maximum size that the output file is allowed to reach |
|
| 53 | + * before being rolled over to backup files. |
|
| 54 | + * |
|
| 55 | + * <p>In configuration files, the <var>MaxFileSize</var> option takes a |
|
| 56 | + * long integer in the range 0 - 2^63. You can specify the value |
|
| 57 | + * with the suffixes "KB", "MB" or "GB" so that the integer is |
|
| 58 | + * interpreted being expressed respectively in kilobytes, megabytes |
|
| 59 | + * or gigabytes. For example, the value "10KB" will be interpreted |
|
| 60 | + * as 10240.</p> |
|
| 61 | + * <p>The default maximum file size is 10MB.</p> |
|
| 62 | + * |
|
| 63 | + * <p>Note that MaxFileSize cannot exceed <b>2 GB</b>.</p> |
|
| 64 | + * |
|
| 65 | + * @var integer |
|
| 66 | + */ |
|
| 67 | + protected $maxFileSize = 10485760; |
|
| 68 | 68 | |
| 69 | - /** |
|
| 70 | - * Set the maximum number of backup files to keep around. |
|
| 71 | - * |
|
| 72 | - * <p>The <var>MaxBackupIndex</var> option determines how many backup |
|
| 73 | - * files are kept before the oldest is erased. This option takes |
|
| 74 | - * a positive integer value. If set to zero, then there will be no |
|
| 75 | - * backup files and the log file will be truncated when it reaches |
|
| 76 | - * MaxFileSize.</p> |
|
| 77 | - * <p>There is one backup file by default.</p> |
|
| 78 | - * |
|
| 79 | - * @var integer |
|
| 80 | - */ |
|
| 81 | - protected $maxBackupIndex = 1; |
|
| 69 | + /** |
|
| 70 | + * Set the maximum number of backup files to keep around. |
|
| 71 | + * |
|
| 72 | + * <p>The <var>MaxBackupIndex</var> option determines how many backup |
|
| 73 | + * files are kept before the oldest is erased. This option takes |
|
| 74 | + * a positive integer value. If set to zero, then there will be no |
|
| 75 | + * backup files and the log file will be truncated when it reaches |
|
| 76 | + * MaxFileSize.</p> |
|
| 77 | + * <p>There is one backup file by default.</p> |
|
| 78 | + * |
|
| 79 | + * @var integer |
|
| 80 | + */ |
|
| 81 | + protected $maxBackupIndex = 1; |
|
| 82 | 82 | |
| 83 | - /** |
|
| 84 | - * @var string the filename expanded |
|
| 85 | - */ |
|
| 86 | - private $expandedFileName = null; |
|
| 83 | + /** |
|
| 84 | + * @var string the filename expanded |
|
| 85 | + */ |
|
| 86 | + private $expandedFileName = null; |
|
| 87 | 87 | |
| 88 | - /** |
|
| 89 | - * Returns the value of the MaxBackupIndex option. |
|
| 90 | - * @return integer |
|
| 91 | - */ |
|
| 92 | - private function getExpandedFileName() { |
|
| 93 | - return $this->expandedFileName; |
|
| 94 | - } |
|
| 88 | + /** |
|
| 89 | + * Returns the value of the MaxBackupIndex option. |
|
| 90 | + * @return integer |
|
| 91 | + */ |
|
| 92 | + private function getExpandedFileName() { |
|
| 93 | + return $this->expandedFileName; |
|
| 94 | + } |
|
| 95 | 95 | |
| 96 | - /** |
|
| 97 | - * Get the maximum size that the output file is allowed to reach |
|
| 98 | - * before being rolled over to backup files. |
|
| 99 | - * @return integer |
|
| 100 | - */ |
|
| 101 | - public function getMaximumFileSize() { |
|
| 102 | - return $this->maxFileSize; |
|
| 103 | - } |
|
| 96 | + /** |
|
| 97 | + * Get the maximum size that the output file is allowed to reach |
|
| 98 | + * before being rolled over to backup files. |
|
| 99 | + * @return integer |
|
| 100 | + */ |
|
| 101 | + public function getMaximumFileSize() { |
|
| 102 | + return $this->maxFileSize; |
|
| 103 | + } |
|
| 104 | 104 | |
| 105 | - /** |
|
| 106 | - * Implements the usual roll over behaviour. |
|
| 107 | - * |
|
| 108 | - * <p>If MaxBackupIndex is positive, then files File.1, ..., File.MaxBackupIndex -1 are renamed to File.2, ..., File.MaxBackupIndex. |
|
| 109 | - * Moreover, File is renamed File.1 and closed. A new File is created to receive further log output. |
|
| 110 | - * |
|
| 111 | - * <p>If MaxBackupIndex is equal to zero, then the File is truncated with no backup files created. |
|
| 112 | - * |
|
| 113 | - * Rollover must be called while the file is locked so that it is safe for concurrent access. |
|
| 114 | - */ |
|
| 115 | - private function rollOver() { |
|
| 116 | - // If maxBackups <= 0, then there is no file renaming to be done. |
|
| 117 | - if($this->maxBackupIndex > 0) { |
|
| 118 | - $fileName = $this->getExpandedFileName(); |
|
| 105 | + /** |
|
| 106 | + * Implements the usual roll over behaviour. |
|
| 107 | + * |
|
| 108 | + * <p>If MaxBackupIndex is positive, then files File.1, ..., File.MaxBackupIndex -1 are renamed to File.2, ..., File.MaxBackupIndex. |
|
| 109 | + * Moreover, File is renamed File.1 and closed. A new File is created to receive further log output. |
|
| 110 | + * |
|
| 111 | + * <p>If MaxBackupIndex is equal to zero, then the File is truncated with no backup files created. |
|
| 112 | + * |
|
| 113 | + * Rollover must be called while the file is locked so that it is safe for concurrent access. |
|
| 114 | + */ |
|
| 115 | + private function rollOver() { |
|
| 116 | + // If maxBackups <= 0, then there is no file renaming to be done. |
|
| 117 | + if($this->maxBackupIndex > 0) { |
|
| 118 | + $fileName = $this->getExpandedFileName(); |
|
| 119 | 119 | |
| 120 | - // Delete the oldest file, to keep Windows happy. |
|
| 121 | - $file = $fileName . '.' . $this->maxBackupIndex; |
|
| 122 | - if(is_writable($file)) |
|
| 123 | - unlink($file); |
|
| 120 | + // Delete the oldest file, to keep Windows happy. |
|
| 121 | + $file = $fileName . '.' . $this->maxBackupIndex; |
|
| 122 | + if(is_writable($file)) |
|
| 123 | + unlink($file); |
|
| 124 | 124 | |
| 125 | - // Map {(maxBackupIndex - 1), ..., 2, 1} to {maxBackupIndex, ..., 3, 2} |
|
| 126 | - for($i = $this->maxBackupIndex - 1; $i >= 1; $i--) { |
|
| 127 | - $file = $fileName . "." . $i; |
|
| 128 | - if(is_readable($file)) { |
|
| 129 | - $target = $fileName . '.' . ($i + 1); |
|
| 130 | - rename($file, $target); |
|
| 131 | - } |
|
| 132 | - } |
|
| 125 | + // Map {(maxBackupIndex - 1), ..., 2, 1} to {maxBackupIndex, ..., 3, 2} |
|
| 126 | + for($i = $this->maxBackupIndex - 1; $i >= 1; $i--) { |
|
| 127 | + $file = $fileName . "." . $i; |
|
| 128 | + if(is_readable($file)) { |
|
| 129 | + $target = $fileName . '.' . ($i + 1); |
|
| 130 | + rename($file, $target); |
|
| 131 | + } |
|
| 132 | + } |
|
| 133 | 133 | |
| 134 | - // Backup the active file |
|
| 135 | - copy($fileName, "$fileName.1"); |
|
| 136 | - } |
|
| 134 | + // Backup the active file |
|
| 135 | + copy($fileName, "$fileName.1"); |
|
| 136 | + } |
|
| 137 | 137 | |
| 138 | - // Truncate the active file |
|
| 139 | - ftruncate($this->fp, 0); |
|
| 140 | - rewind($this->fp); |
|
| 141 | - } |
|
| 138 | + // Truncate the active file |
|
| 139 | + ftruncate($this->fp, 0); |
|
| 140 | + rewind($this->fp); |
|
| 141 | + } |
|
| 142 | 142 | |
| 143 | - public function setFile($fileName) { |
|
| 144 | - $this->file = $fileName; |
|
| 145 | - // As Payone_Log4php_LoggerAppenderFile does not create the directory, it has to exist. |
|
| 146 | - // realpath() fails if the argument does not exist so the filename is separated. |
|
| 147 | - $this->expandedFileName = realpath(dirname($fileName)); |
|
| 148 | - if ($this->expandedFileName === false) throw new Exception("Directory of $fileName does not exist!"); |
|
| 149 | - $this->expandedFileName .= DIRECTORY_SEPARATOR . basename($fileName); |
|
| 150 | - } |
|
| 143 | + public function setFile($fileName) { |
|
| 144 | + $this->file = $fileName; |
|
| 145 | + // As Payone_Log4php_LoggerAppenderFile does not create the directory, it has to exist. |
|
| 146 | + // realpath() fails if the argument does not exist so the filename is separated. |
|
| 147 | + $this->expandedFileName = realpath(dirname($fileName)); |
|
| 148 | + if ($this->expandedFileName === false) throw new Exception("Directory of $fileName does not exist!"); |
|
| 149 | + $this->expandedFileName .= DIRECTORY_SEPARATOR . basename($fileName); |
|
| 150 | + } |
|
| 151 | 151 | |
| 152 | 152 | |
| 153 | - /** |
|
| 154 | - * Set the maximum number of backup files to keep around. |
|
| 155 | - * |
|
| 156 | - * <p>The <b>MaxBackupIndex</b> option determines how many backup |
|
| 157 | - * files are kept before the oldest is erased. This option takes |
|
| 158 | - * a positive integer value. If set to zero, then there will be no |
|
| 159 | - * backup files and the log file will be truncated when it reaches |
|
| 160 | - * MaxFileSize. |
|
| 161 | - * |
|
| 162 | - * @param mixed $maxBackups |
|
| 163 | - */ |
|
| 164 | - public function setMaxBackupIndex($maxBackups) { |
|
| 165 | - $this->setPositiveInteger('maxBackupIndex', $maxBackups); |
|
| 166 | - } |
|
| 153 | + /** |
|
| 154 | + * Set the maximum number of backup files to keep around. |
|
| 155 | + * |
|
| 156 | + * <p>The <b>MaxBackupIndex</b> option determines how many backup |
|
| 157 | + * files are kept before the oldest is erased. This option takes |
|
| 158 | + * a positive integer value. If set to zero, then there will be no |
|
| 159 | + * backup files and the log file will be truncated when it reaches |
|
| 160 | + * MaxFileSize. |
|
| 161 | + * |
|
| 162 | + * @param mixed $maxBackups |
|
| 163 | + */ |
|
| 164 | + public function setMaxBackupIndex($maxBackups) { |
|
| 165 | + $this->setPositiveInteger('maxBackupIndex', $maxBackups); |
|
| 166 | + } |
|
| 167 | 167 | |
| 168 | - /** |
|
| 169 | - * Set the maximum size that the output file is allowed to reach |
|
| 170 | - * before being rolled over to backup files. |
|
| 171 | - * |
|
| 172 | - * @param mixed $maxFileSize |
|
| 173 | - * @see setMaxFileSize() |
|
| 174 | - * @deprecated |
|
| 175 | - */ |
|
| 176 | - public function setMaximumFileSize($maxFileSize) { |
|
| 177 | - return $this->setMaxFileSize($maxFileSize); |
|
| 178 | - } |
|
| 168 | + /** |
|
| 169 | + * Set the maximum size that the output file is allowed to reach |
|
| 170 | + * before being rolled over to backup files. |
|
| 171 | + * |
|
| 172 | + * @param mixed $maxFileSize |
|
| 173 | + * @see setMaxFileSize() |
|
| 174 | + * @deprecated |
|
| 175 | + */ |
|
| 176 | + public function setMaximumFileSize($maxFileSize) { |
|
| 177 | + return $this->setMaxFileSize($maxFileSize); |
|
| 178 | + } |
|
| 179 | 179 | |
| 180 | - /** |
|
| 181 | - * Set the maximum size that the output file is allowed to reach |
|
| 182 | - * before being rolled over to backup files. |
|
| 183 | - * <p>In configuration files, the <b>maxFileSize</b> option takes an |
|
| 184 | - * long integer in the range 0 - 2^63. You can specify the value |
|
| 185 | - * with the suffixes "KB", "MB" or "GB" so that the integer is |
|
| 186 | - * interpreted being expressed respectively in kilobytes, megabytes |
|
| 187 | - * or gigabytes. For example, the value "10KB" will be interpreted |
|
| 188 | - * as 10240. |
|
| 189 | - * |
|
| 190 | - * @param mixed $value |
|
| 191 | - * @return the actual file size set |
|
| 192 | - */ |
|
| 193 | - public function setMaxFileSize($value) { |
|
| 194 | - $this->setFileSize('maxFileSize', $value); |
|
| 195 | - } |
|
| 180 | + /** |
|
| 181 | + * Set the maximum size that the output file is allowed to reach |
|
| 182 | + * before being rolled over to backup files. |
|
| 183 | + * <p>In configuration files, the <b>maxFileSize</b> option takes an |
|
| 184 | + * long integer in the range 0 - 2^63. You can specify the value |
|
| 185 | + * with the suffixes "KB", "MB" or "GB" so that the integer is |
|
| 186 | + * interpreted being expressed respectively in kilobytes, megabytes |
|
| 187 | + * or gigabytes. For example, the value "10KB" will be interpreted |
|
| 188 | + * as 10240. |
|
| 189 | + * |
|
| 190 | + * @param mixed $value |
|
| 191 | + * @return the actual file size set |
|
| 192 | + */ |
|
| 193 | + public function setMaxFileSize($value) { |
|
| 194 | + $this->setFileSize('maxFileSize', $value); |
|
| 195 | + } |
|
| 196 | 196 | |
| 197 | - public function append(Payone_Log4php_LoggerLoggingEvent $event) { |
|
| 198 | - if($this->fp and $this->layout !== null) { |
|
| 199 | - if(flock($this->fp, LOCK_EX)) { |
|
| 200 | - fwrite($this->fp, $this->layout->format($event)); |
|
| 197 | + public function append(Payone_Log4php_LoggerLoggingEvent $event) { |
|
| 198 | + if($this->fp and $this->layout !== null) { |
|
| 199 | + if(flock($this->fp, LOCK_EX)) { |
|
| 200 | + fwrite($this->fp, $this->layout->format($event)); |
|
| 201 | 201 | |
| 202 | - // Stats cache must be cleared, otherwise filesize() returns cached results |
|
| 203 | - clearstatcache(); |
|
| 202 | + // Stats cache must be cleared, otherwise filesize() returns cached results |
|
| 203 | + clearstatcache(); |
|
| 204 | 204 | |
| 205 | - // Rollover if needed |
|
| 206 | - if (filesize($this->expandedFileName) > $this->maxFileSize) { |
|
| 207 | - $this->rollOver(); |
|
| 208 | - } |
|
| 205 | + // Rollover if needed |
|
| 206 | + if (filesize($this->expandedFileName) > $this->maxFileSize) { |
|
| 207 | + $this->rollOver(); |
|
| 208 | + } |
|
| 209 | 209 | |
| 210 | - flock($this->fp, LOCK_UN); |
|
| 211 | - } else { |
|
| 212 | - $this->closed = true; |
|
| 213 | - } |
|
| 214 | - } |
|
| 215 | - } |
|
| 210 | + flock($this->fp, LOCK_UN); |
|
| 211 | + } else { |
|
| 212 | + $this->closed = true; |
|
| 213 | + } |
|
| 214 | + } |
|
| 215 | + } |
|
| 216 | 216 | |
| 217 | - /** |
|
| 218 | - * @return Returns the maximum number of backup files to keep around. |
|
| 219 | - */ |
|
| 220 | - public function getMaxBackupIndex() { |
|
| 221 | - return $this->maxBackupIndex; |
|
| 222 | - } |
|
| 217 | + /** |
|
| 218 | + * @return Returns the maximum number of backup files to keep around. |
|
| 219 | + */ |
|
| 220 | + public function getMaxBackupIndex() { |
|
| 221 | + return $this->maxBackupIndex; |
|
| 222 | + } |
|
| 223 | 223 | |
| 224 | - /** |
|
| 225 | - * @return Returns the maximum size that the output file is allowed to reach |
|
| 226 | - * before being rolled over to backup files. |
|
| 227 | - */ |
|
| 228 | - public function getMaxFileSize() { |
|
| 229 | - return $this->maxFileSize; |
|
| 230 | - } |
|
| 224 | + /** |
|
| 225 | + * @return Returns the maximum size that the output file is allowed to reach |
|
| 226 | + * before being rolled over to backup files. |
|
| 227 | + */ |
|
| 228 | + public function getMaxFileSize() { |
|
| 229 | + return $this->maxFileSize; |
|
| 230 | + } |
|
| 231 | 231 | } |
@@ -73,233 +73,233 @@ |
||
| 73 | 73 | */ |
| 74 | 74 | class Payone_Log4php_LoggerAppenderSyslog extends Payone_Log4php_LoggerAppender { |
| 75 | 75 | |
| 76 | - /** |
|
| 77 | - * The ident string is added to each message. Typically the name of your application. |
|
| 78 | - * |
|
| 79 | - * @var string |
|
| 80 | - */ |
|
| 81 | - protected $ident = "Apache log4php"; |
|
| 76 | + /** |
|
| 77 | + * The ident string is added to each message. Typically the name of your application. |
|
| 78 | + * |
|
| 79 | + * @var string |
|
| 80 | + */ |
|
| 81 | + protected $ident = "Apache log4php"; |
|
| 82 | 82 | |
| 83 | - /** |
|
| 84 | - * The syslog priority to use when overriding priority. This setting is |
|
| 85 | - * required if {@link overridePriority} is set to true. |
|
| 86 | - * |
|
| 87 | - * @var string |
|
| 88 | - */ |
|
| 89 | - protected $priority; |
|
| 83 | + /** |
|
| 84 | + * The syslog priority to use when overriding priority. This setting is |
|
| 85 | + * required if {@link overridePriority} is set to true. |
|
| 86 | + * |
|
| 87 | + * @var string |
|
| 88 | + */ |
|
| 89 | + protected $priority; |
|
| 90 | 90 | |
| 91 | - /** |
|
| 92 | - * The option used when opening the syslog connection. |
|
| 93 | - * |
|
| 94 | - * @var string |
|
| 95 | - */ |
|
| 96 | - protected $option = 'PID|CONS'; |
|
| 91 | + /** |
|
| 92 | + * The option used when opening the syslog connection. |
|
| 93 | + * |
|
| 94 | + * @var string |
|
| 95 | + */ |
|
| 96 | + protected $option = 'PID|CONS'; |
|
| 97 | 97 | |
| 98 | - /** |
|
| 99 | - * The facility value indicates the source of the message. |
|
| 100 | - * |
|
| 101 | - * @var string |
|
| 102 | - */ |
|
| 103 | - protected $facility = 'USER'; |
|
| 98 | + /** |
|
| 99 | + * The facility value indicates the source of the message. |
|
| 100 | + * |
|
| 101 | + * @var string |
|
| 102 | + */ |
|
| 103 | + protected $facility = 'USER'; |
|
| 104 | 104 | |
| 105 | - /** |
|
| 106 | - * If set to true, the message priority will always use the value defined |
|
| 107 | - * in {@link $priority}, otherwise the priority will be determined by the |
|
| 108 | - * message's log level. |
|
| 109 | - * |
|
| 110 | - * @var string |
|
| 111 | - */ |
|
| 112 | - protected $overridePriority = false; |
|
| 105 | + /** |
|
| 106 | + * If set to true, the message priority will always use the value defined |
|
| 107 | + * in {@link $priority}, otherwise the priority will be determined by the |
|
| 108 | + * message's log level. |
|
| 109 | + * |
|
| 110 | + * @var string |
|
| 111 | + */ |
|
| 112 | + protected $overridePriority = false; |
|
| 113 | 113 | |
| 114 | - /** |
|
| 115 | - * Holds the int value of the {@link $priority}. |
|
| 116 | - * @var int |
|
| 117 | - */ |
|
| 118 | - private $intPriority; |
|
| 114 | + /** |
|
| 115 | + * Holds the int value of the {@link $priority}. |
|
| 116 | + * @var int |
|
| 117 | + */ |
|
| 118 | + private $intPriority; |
|
| 119 | 119 | |
| 120 | - /** |
|
| 121 | - * Holds the int value of the {@link $facility}. |
|
| 122 | - * @var int |
|
| 123 | - */ |
|
| 124 | - private $intFacility; |
|
| 120 | + /** |
|
| 121 | + * Holds the int value of the {@link $facility}. |
|
| 122 | + * @var int |
|
| 123 | + */ |
|
| 124 | + private $intFacility; |
|
| 125 | 125 | |
| 126 | - /** |
|
| 127 | - * Holds the int value of the {@link $option}. |
|
| 128 | - * @var int |
|
| 129 | - */ |
|
| 130 | - private $intOption; |
|
| 126 | + /** |
|
| 127 | + * Holds the int value of the {@link $option}. |
|
| 128 | + * @var int |
|
| 129 | + */ |
|
| 130 | + private $intOption; |
|
| 131 | 131 | |
| 132 | - /** |
|
| 133 | - * Sets the {@link $ident}. |
|
| 134 | - * |
|
| 135 | - * @param string $ident |
|
| 136 | - */ |
|
| 137 | - public function setIdent($ident) { |
|
| 138 | - $this->ident = $ident; |
|
| 139 | - } |
|
| 132 | + /** |
|
| 133 | + * Sets the {@link $ident}. |
|
| 134 | + * |
|
| 135 | + * @param string $ident |
|
| 136 | + */ |
|
| 137 | + public function setIdent($ident) { |
|
| 138 | + $this->ident = $ident; |
|
| 139 | + } |
|
| 140 | 140 | |
| 141 | - /** |
|
| 142 | - * Sets the {@link $priority}. |
|
| 143 | - * |
|
| 144 | - * @param string $priority |
|
| 145 | - */ |
|
| 146 | - public function setPriority($priority) { |
|
| 147 | - $this->priority = $priority; |
|
| 148 | - } |
|
| 141 | + /** |
|
| 142 | + * Sets the {@link $priority}. |
|
| 143 | + * |
|
| 144 | + * @param string $priority |
|
| 145 | + */ |
|
| 146 | + public function setPriority($priority) { |
|
| 147 | + $this->priority = $priority; |
|
| 148 | + } |
|
| 149 | 149 | |
| 150 | - /** |
|
| 151 | - * Sets the {@link $facility}. |
|
| 152 | - * |
|
| 153 | - * @param string $facility |
|
| 154 | - */ |
|
| 155 | - public function setFacility($facility) { |
|
| 156 | - $this->facility = $facility; |
|
| 157 | - } |
|
| 150 | + /** |
|
| 151 | + * Sets the {@link $facility}. |
|
| 152 | + * |
|
| 153 | + * @param string $facility |
|
| 154 | + */ |
|
| 155 | + public function setFacility($facility) { |
|
| 156 | + $this->facility = $facility; |
|
| 157 | + } |
|
| 158 | 158 | |
| 159 | - /** |
|
| 160 | - * Sets the {@link $overridePriority}. |
|
| 161 | - * |
|
| 162 | - * @param string $overridePriority |
|
| 163 | - */ |
|
| 164 | - public function setOverridePriority($overridePriority) { |
|
| 165 | - $this->overridePriority = $overridePriority; |
|
| 166 | - } |
|
| 159 | + /** |
|
| 160 | + * Sets the {@link $overridePriority}. |
|
| 161 | + * |
|
| 162 | + * @param string $overridePriority |
|
| 163 | + */ |
|
| 164 | + public function setOverridePriority($overridePriority) { |
|
| 165 | + $this->overridePriority = $overridePriority; |
|
| 166 | + } |
|
| 167 | 167 | |
| 168 | - /** |
|
| 169 | - * Sets the {@link $option}. |
|
| 170 | - * |
|
| 171 | - * @param string $option |
|
| 172 | - */ |
|
| 173 | - public function setOption($option) { |
|
| 174 | - $this->option = $option; |
|
| 175 | - } |
|
| 168 | + /** |
|
| 169 | + * Sets the {@link $option}. |
|
| 170 | + * |
|
| 171 | + * @param string $option |
|
| 172 | + */ |
|
| 173 | + public function setOption($option) { |
|
| 174 | + $this->option = $option; |
|
| 175 | + } |
|
| 176 | 176 | |
| 177 | - /** |
|
| 178 | - * Returns the {@link $ident}. |
|
| 179 | - * |
|
| 180 | - * @return string $ident |
|
| 181 | - */ |
|
| 182 | - public function getIdent() { |
|
| 183 | - return $this->ident; |
|
| 184 | - } |
|
| 177 | + /** |
|
| 178 | + * Returns the {@link $ident}. |
|
| 179 | + * |
|
| 180 | + * @return string $ident |
|
| 181 | + */ |
|
| 182 | + public function getIdent() { |
|
| 183 | + return $this->ident; |
|
| 184 | + } |
|
| 185 | 185 | |
| 186 | - /** |
|
| 187 | - * Returns the {@link $priority}. |
|
| 188 | - * |
|
| 189 | - * @return string |
|
| 190 | - */ |
|
| 191 | - public function getPriority() { |
|
| 192 | - return $this->priority; |
|
| 193 | - } |
|
| 186 | + /** |
|
| 187 | + * Returns the {@link $priority}. |
|
| 188 | + * |
|
| 189 | + * @return string |
|
| 190 | + */ |
|
| 191 | + public function getPriority() { |
|
| 192 | + return $this->priority; |
|
| 193 | + } |
|
| 194 | 194 | |
| 195 | - /** |
|
| 196 | - * Returns the {@link $facility}. |
|
| 197 | - * |
|
| 198 | - * @return string |
|
| 199 | - */ |
|
| 200 | - public function getFacility() { |
|
| 201 | - return $this->facility; |
|
| 202 | - } |
|
| 195 | + /** |
|
| 196 | + * Returns the {@link $facility}. |
|
| 197 | + * |
|
| 198 | + * @return string |
|
| 199 | + */ |
|
| 200 | + public function getFacility() { |
|
| 201 | + return $this->facility; |
|
| 202 | + } |
|
| 203 | 203 | |
| 204 | - /** |
|
| 205 | - * Returns the {@link $overridePriority}. |
|
| 206 | - * |
|
| 207 | - * @return string |
|
| 208 | - */ |
|
| 209 | - public function getOverridePriority() { |
|
| 210 | - return $this->overridePriority; |
|
| 211 | - } |
|
| 204 | + /** |
|
| 205 | + * Returns the {@link $overridePriority}. |
|
| 206 | + * |
|
| 207 | + * @return string |
|
| 208 | + */ |
|
| 209 | + public function getOverridePriority() { |
|
| 210 | + return $this->overridePriority; |
|
| 211 | + } |
|
| 212 | 212 | |
| 213 | - /** |
|
| 214 | - * Returns the {@link $option}. |
|
| 215 | - * |
|
| 216 | - * @return string |
|
| 217 | - */ |
|
| 218 | - public function getOption() { |
|
| 219 | - return $this->option; |
|
| 220 | - } |
|
| 213 | + /** |
|
| 214 | + * Returns the {@link $option}. |
|
| 215 | + * |
|
| 216 | + * @return string |
|
| 217 | + */ |
|
| 218 | + public function getOption() { |
|
| 219 | + return $this->option; |
|
| 220 | + } |
|
| 221 | 221 | |
| 222 | 222 | |
| 223 | - public function activateOptions() { |
|
| 224 | - $this->intPriority = $this->parsePriority(); |
|
| 225 | - $this->intOption = $this->parseOption(); |
|
| 226 | - $this->intFacility = $this->parseFacility(); |
|
| 223 | + public function activateOptions() { |
|
| 224 | + $this->intPriority = $this->parsePriority(); |
|
| 225 | + $this->intOption = $this->parseOption(); |
|
| 226 | + $this->intFacility = $this->parseFacility(); |
|
| 227 | 227 | |
| 228 | - $this->closed = false; |
|
| 229 | - } |
|
| 228 | + $this->closed = false; |
|
| 229 | + } |
|
| 230 | 230 | |
| 231 | - public function close() { |
|
| 232 | - if($this->closed != true) { |
|
| 233 | - closelog(); |
|
| 234 | - $this->closed = true; |
|
| 235 | - } |
|
| 236 | - } |
|
| 231 | + public function close() { |
|
| 232 | + if($this->closed != true) { |
|
| 233 | + closelog(); |
|
| 234 | + $this->closed = true; |
|
| 235 | + } |
|
| 236 | + } |
|
| 237 | 237 | |
| 238 | - /** |
|
| 239 | - * Appends the event to syslog. |
|
| 240 | - * |
|
| 241 | - * Log is opened and closed each time because if it is not closed, it |
|
| 242 | - * can cause the Apache httpd server to log to whatever ident/facility |
|
| 243 | - * was used in openlog(). |
|
| 244 | - * |
|
| 245 | - * @see http://www.php.net/manual/en/function.syslog.php#97843 |
|
| 246 | - */ |
|
| 247 | - public function append(Payone_Log4php_LoggerLoggingEvent $event) { |
|
| 248 | - $priority = $this->getSyslogPriority($event->getLevel()); |
|
| 249 | - $message = $this->layout->format($event); |
|
| 238 | + /** |
|
| 239 | + * Appends the event to syslog. |
|
| 240 | + * |
|
| 241 | + * Log is opened and closed each time because if it is not closed, it |
|
| 242 | + * can cause the Apache httpd server to log to whatever ident/facility |
|
| 243 | + * was used in openlog(). |
|
| 244 | + * |
|
| 245 | + * @see http://www.php.net/manual/en/function.syslog.php#97843 |
|
| 246 | + */ |
|
| 247 | + public function append(Payone_Log4php_LoggerLoggingEvent $event) { |
|
| 248 | + $priority = $this->getSyslogPriority($event->getLevel()); |
|
| 249 | + $message = $this->layout->format($event); |
|
| 250 | 250 | |
| 251 | - openlog($this->ident, $this->intOption, $this->intFacility); |
|
| 252 | - syslog($priority, $message); |
|
| 253 | - closelog(); |
|
| 254 | - } |
|
| 251 | + openlog($this->ident, $this->intOption, $this->intFacility); |
|
| 252 | + syslog($priority, $message); |
|
| 253 | + closelog(); |
|
| 254 | + } |
|
| 255 | 255 | |
| 256 | - /** Determines which syslog priority to use based on the given level. */ |
|
| 257 | - private function getSyslogPriority(Payone_Log4php_LoggerLevel $level) { |
|
| 258 | - if($this->overridePriority) { |
|
| 259 | - return $this->intPriority; |
|
| 260 | - } |
|
| 261 | - return $level->getSyslogEquivalent(); |
|
| 262 | - } |
|
| 256 | + /** Determines which syslog priority to use based on the given level. */ |
|
| 257 | + private function getSyslogPriority(Payone_Log4php_LoggerLevel $level) { |
|
| 258 | + if($this->overridePriority) { |
|
| 259 | + return $this->intPriority; |
|
| 260 | + } |
|
| 261 | + return $level->getSyslogEquivalent(); |
|
| 262 | + } |
|
| 263 | 263 | |
| 264 | - /** Parses a syslog option string and returns the correspodning int value. */ |
|
| 265 | - private function parseOption() { |
|
| 266 | - $value = 0; |
|
| 267 | - $options = explode('|', $this->option); |
|
| 264 | + /** Parses a syslog option string and returns the correspodning int value. */ |
|
| 265 | + private function parseOption() { |
|
| 266 | + $value = 0; |
|
| 267 | + $options = explode('|', $this->option); |
|
| 268 | 268 | |
| 269 | - foreach($options as $option) { |
|
| 270 | - if (!empty($option)) { |
|
| 271 | - $constant = "LOG_" . trim($option); |
|
| 272 | - if (defined($constant)) { |
|
| 273 | - $value |= constant($constant); |
|
| 274 | - } else { |
|
| 275 | - trigger_error("log4php: Invalid syslog option provided: $option. Whole option string: {$this->option}.", E_USER_WARNING); |
|
| 276 | - } |
|
| 277 | - } |
|
| 278 | - } |
|
| 279 | - return $value; |
|
| 280 | - } |
|
| 269 | + foreach($options as $option) { |
|
| 270 | + if (!empty($option)) { |
|
| 271 | + $constant = "LOG_" . trim($option); |
|
| 272 | + if (defined($constant)) { |
|
| 273 | + $value |= constant($constant); |
|
| 274 | + } else { |
|
| 275 | + trigger_error("log4php: Invalid syslog option provided: $option. Whole option string: {$this->option}.", E_USER_WARNING); |
|
| 276 | + } |
|
| 277 | + } |
|
| 278 | + } |
|
| 279 | + return $value; |
|
| 280 | + } |
|
| 281 | 281 | |
| 282 | - /** Parses the facility string and returns the corresponding int value. */ |
|
| 283 | - private function parseFacility() { |
|
| 284 | - if (!empty($this->facility)) { |
|
| 285 | - $constant = "LOG_" . trim($this->facility); |
|
| 286 | - if (defined($constant)) { |
|
| 287 | - return constant($constant); |
|
| 288 | - } else { |
|
| 289 | - trigger_error("log4php: Invalid syslog facility provided: {$this->facility}.", E_USER_WARNING); |
|
| 290 | - } |
|
| 291 | - } |
|
| 292 | - } |
|
| 282 | + /** Parses the facility string and returns the corresponding int value. */ |
|
| 283 | + private function parseFacility() { |
|
| 284 | + if (!empty($this->facility)) { |
|
| 285 | + $constant = "LOG_" . trim($this->facility); |
|
| 286 | + if (defined($constant)) { |
|
| 287 | + return constant($constant); |
|
| 288 | + } else { |
|
| 289 | + trigger_error("log4php: Invalid syslog facility provided: {$this->facility}.", E_USER_WARNING); |
|
| 290 | + } |
|
| 291 | + } |
|
| 292 | + } |
|
| 293 | 293 | |
| 294 | - /** Parses the priority string and returns the corresponding int value. */ |
|
| 295 | - private function parsePriority() { |
|
| 296 | - if (!empty($this->priority)) { |
|
| 297 | - $constant = "LOG_" . trim($this->priority); |
|
| 298 | - if (defined($constant)) { |
|
| 299 | - return constant($constant); |
|
| 300 | - } else { |
|
| 301 | - trigger_error("log4php: Invalid syslog priority provided: {$this->priority}.", E_USER_WARNING); |
|
| 302 | - } |
|
| 303 | - } |
|
| 304 | - } |
|
| 294 | + /** Parses the priority string and returns the corresponding int value. */ |
|
| 295 | + private function parsePriority() { |
|
| 296 | + if (!empty($this->priority)) { |
|
| 297 | + $constant = "LOG_" . trim($this->priority); |
|
| 298 | + if (defined($constant)) { |
|
| 299 | + return constant($constant); |
|
| 300 | + } else { |
|
| 301 | + trigger_error("log4php: Invalid syslog priority provided: {$this->priority}.", E_USER_WARNING); |
|
| 302 | + } |
|
| 303 | + } |
|
| 304 | + } |
|
| 305 | 305 | } |
@@ -19,7 +19,7 @@ discard block |
||
| 19 | 19 | */ |
| 20 | 20 | |
| 21 | 21 | if (function_exists('__autoload')) { |
| 22 | - //trigger_error("log4php: It looks like your code is using an __autoload() function. log4php uses spl_autoload_register() which will bypass your __autoload() function and may break autoloading.", E_USER_WARNING); |
|
| 22 | + //trigger_error("log4php: It looks like your code is using an __autoload() function. log4php uses spl_autoload_register() which will bypass your __autoload() function and may break autoloading.", E_USER_WARNING); |
|
| 23 | 23 | } |
| 24 | 24 | |
| 25 | 25 | spl_autoload_register(array('Payone_Log4php_LoggerAutoloader', 'autoload')); |
@@ -33,108 +33,108 @@ discard block |
||
| 33 | 33 | */ |
| 34 | 34 | class Payone_Log4php_LoggerAutoloader { |
| 35 | 35 | |
| 36 | - /** Maps classnames to files containing the class. */ |
|
| 37 | - private static $classes = array( |
|
| 36 | + /** Maps classnames to files containing the class. */ |
|
| 37 | + private static $classes = array( |
|
| 38 | 38 | |
| 39 | - // Base |
|
| 40 | - 'Payone_Log4php_LoggerAppender' => '/LoggerAppender.php', |
|
| 41 | - 'Payone_Log4php_LoggerAppenderPool' => '/LoggerAppenderPool.php', |
|
| 42 | - 'Payone_Log4php_LoggerConfigurable' => '/LoggerConfigurable.php', |
|
| 43 | - 'Payone_Log4php_LoggerConfigurator' => '/LoggerConfigurator.php', |
|
| 44 | - 'Payone_Log4php_LoggerException' => '/LoggerException.php', |
|
| 45 | - 'Payone_Log4php_LoggerFilter' => '/LoggerFilter.php', |
|
| 46 | - 'Payone_Log4php_LoggerHierarchy' => '/LoggerHierarchy.php', |
|
| 47 | - 'Payone_Log4php_LoggerLevel' => '/LoggerLevel.php', |
|
| 48 | - 'Payone_Log4php_LoggerLocationInfo' => '/LoggerLocationInfo.php', |
|
| 49 | - 'Payone_Log4php_LoggerLoggingEvent' => '/LoggerLoggingEvent.php', |
|
| 50 | - 'Payone_Log4php_LoggerMDC' => '/LoggerMDC.php', |
|
| 51 | - 'Payone_Log4php_LoggerNDC' => '/LoggerNDC.php', |
|
| 52 | - 'Payone_Log4php_LoggerLayout' => '/LoggerLayout.php', |
|
| 53 | - 'Payone_Log4php_LoggerReflectionUtils' => '/LoggerReflectionUtils.php', |
|
| 54 | - 'Payone_Log4php_LoggerRoot' => '/LoggerRoot.php', |
|
| 55 | - 'Payone_Log4php_LoggerThrowableInformation' => '/LoggerThrowableInformation.php', |
|
| 39 | + // Base |
|
| 40 | + 'Payone_Log4php_LoggerAppender' => '/LoggerAppender.php', |
|
| 41 | + 'Payone_Log4php_LoggerAppenderPool' => '/LoggerAppenderPool.php', |
|
| 42 | + 'Payone_Log4php_LoggerConfigurable' => '/LoggerConfigurable.php', |
|
| 43 | + 'Payone_Log4php_LoggerConfigurator' => '/LoggerConfigurator.php', |
|
| 44 | + 'Payone_Log4php_LoggerException' => '/LoggerException.php', |
|
| 45 | + 'Payone_Log4php_LoggerFilter' => '/LoggerFilter.php', |
|
| 46 | + 'Payone_Log4php_LoggerHierarchy' => '/LoggerHierarchy.php', |
|
| 47 | + 'Payone_Log4php_LoggerLevel' => '/LoggerLevel.php', |
|
| 48 | + 'Payone_Log4php_LoggerLocationInfo' => '/LoggerLocationInfo.php', |
|
| 49 | + 'Payone_Log4php_LoggerLoggingEvent' => '/LoggerLoggingEvent.php', |
|
| 50 | + 'Payone_Log4php_LoggerMDC' => '/LoggerMDC.php', |
|
| 51 | + 'Payone_Log4php_LoggerNDC' => '/LoggerNDC.php', |
|
| 52 | + 'Payone_Log4php_LoggerLayout' => '/LoggerLayout.php', |
|
| 53 | + 'Payone_Log4php_LoggerReflectionUtils' => '/LoggerReflectionUtils.php', |
|
| 54 | + 'Payone_Log4php_LoggerRoot' => '/LoggerRoot.php', |
|
| 55 | + 'Payone_Log4php_LoggerThrowableInformation' => '/LoggerThrowableInformation.php', |
|
| 56 | 56 | |
| 57 | - // Appenders |
|
| 58 | - 'Payone_Log4php_LoggerAppenderConsole' => '/LoggerAppenderConsole.php', |
|
| 59 | - 'Payone_Log4php_LoggerAppenderDailyFile' => '/LoggerAppenderDailyFile.php', |
|
| 60 | - 'Payone_Log4php_LoggerAppenderEcho' => '/LoggerAppenderEcho.php', |
|
| 61 | - 'Payone_Log4php_LoggerAppenderFile' => '/LoggerAppenderFile.php', |
|
| 62 | - 'Payone_Log4php_LoggerAppenderMail' => '/LoggerAppenderMail.php', |
|
| 63 | - 'Payone_Log4php_LoggerAppenderMailEvent' => '/LoggerAppenderMailEvent.php', |
|
| 64 | - 'Payone_Log4php_LoggerAppenderMongoDB' => '/LoggerAppenderMongoDB.php', |
|
| 65 | - 'Payone_Log4php_LoggerAppenderNull' => '/LoggerAppenderNull.php', |
|
| 66 | - 'Payone_Log4php_LoggerAppenderPDO' => '/LoggerAppenderPDO.php', |
|
| 67 | - 'Payone_Log4php_LoggerAppenderPhp' => '/LoggerAppenderPhp.php', |
|
| 68 | - 'Payone_Log4php_LoggerAppenderRollingFile' => '/LoggerAppenderRollingFile.php', |
|
| 69 | - 'Payone_Log4php_LoggerAppenderSocket' => '/LoggerAppenderSocket.php', |
|
| 70 | - 'Payone_Log4php_LoggerAppenderSyslog' => '/LoggerAppenderSyslog.php', |
|
| 57 | + // Appenders |
|
| 58 | + 'Payone_Log4php_LoggerAppenderConsole' => '/LoggerAppenderConsole.php', |
|
| 59 | + 'Payone_Log4php_LoggerAppenderDailyFile' => '/LoggerAppenderDailyFile.php', |
|
| 60 | + 'Payone_Log4php_LoggerAppenderEcho' => '/LoggerAppenderEcho.php', |
|
| 61 | + 'Payone_Log4php_LoggerAppenderFile' => '/LoggerAppenderFile.php', |
|
| 62 | + 'Payone_Log4php_LoggerAppenderMail' => '/LoggerAppenderMail.php', |
|
| 63 | + 'Payone_Log4php_LoggerAppenderMailEvent' => '/LoggerAppenderMailEvent.php', |
|
| 64 | + 'Payone_Log4php_LoggerAppenderMongoDB' => '/LoggerAppenderMongoDB.php', |
|
| 65 | + 'Payone_Log4php_LoggerAppenderNull' => '/LoggerAppenderNull.php', |
|
| 66 | + 'Payone_Log4php_LoggerAppenderPDO' => '/LoggerAppenderPDO.php', |
|
| 67 | + 'Payone_Log4php_LoggerAppenderPhp' => '/LoggerAppenderPhp.php', |
|
| 68 | + 'Payone_Log4php_LoggerAppenderRollingFile' => '/LoggerAppenderRollingFile.php', |
|
| 69 | + 'Payone_Log4php_LoggerAppenderSocket' => '/LoggerAppenderSocket.php', |
|
| 70 | + 'Payone_Log4php_LoggerAppenderSyslog' => '/LoggerAppenderSyslog.php', |
|
| 71 | 71 | |
| 72 | - // Configurators |
|
| 73 | - 'Payone_Log4php_LoggerConfigurationAdapter' => '/LoggerConfigurationAdapter.php', |
|
| 74 | - 'Payone_Log4php_LoggerConfigurationAdapterINI' => '/LoggerConfigurationAdapterINI.php', |
|
| 75 | - 'Payone_Log4php_LoggerConfigurationAdapterPHP' => '/LoggerConfigurationAdapterPHP.php', |
|
| 76 | - 'Payone_Log4php_LoggerConfigurationAdapterXML' => '/LoggerConfigurationAdapterXML.php', |
|
| 77 | - 'Payone_Log4php_LoggerConfiguratorDefault' => '/LoggerConfiguratorDefault.php', |
|
| 72 | + // Configurators |
|
| 73 | + 'Payone_Log4php_LoggerConfigurationAdapter' => '/LoggerConfigurationAdapter.php', |
|
| 74 | + 'Payone_Log4php_LoggerConfigurationAdapterINI' => '/LoggerConfigurationAdapterINI.php', |
|
| 75 | + 'Payone_Log4php_LoggerConfigurationAdapterPHP' => '/LoggerConfigurationAdapterPHP.php', |
|
| 76 | + 'Payone_Log4php_LoggerConfigurationAdapterXML' => '/LoggerConfigurationAdapterXML.php', |
|
| 77 | + 'Payone_Log4php_LoggerConfiguratorDefault' => '/LoggerConfiguratorDefault.php', |
|
| 78 | 78 | |
| 79 | - // Filters |
|
| 80 | - 'Payone_Log4php_LoggerFilterDenyAll' => '/LoggerFilterDenyAll.php', |
|
| 81 | - 'Payone_Log4php_LoggerFilterLevelMatch' => '/LoggerFilterLevelMatch.php', |
|
| 82 | - 'Payone_Log4php_LoggerFilterLevelRange' => '/LoggerFilterLevelRange.php', |
|
| 83 | - 'Payone_Log4php_LoggerFilterStringMatch' => '/LoggerFilterStringMatch.php', |
|
| 79 | + // Filters |
|
| 80 | + 'Payone_Log4php_LoggerFilterDenyAll' => '/LoggerFilterDenyAll.php', |
|
| 81 | + 'Payone_Log4php_LoggerFilterLevelMatch' => '/LoggerFilterLevelMatch.php', |
|
| 82 | + 'Payone_Log4php_LoggerFilterLevelRange' => '/LoggerFilterLevelRange.php', |
|
| 83 | + 'Payone_Log4php_LoggerFilterStringMatch' => '/LoggerFilterStringMatch.php', |
|
| 84 | 84 | |
| 85 | - // Helpers |
|
| 86 | - 'Payone_Log4php_LoggerFormattingInfo' => '/LoggerFormattingInfo.php', |
|
| 87 | - 'Payone_Log4php_LoggerOptionConverter' => '/LoggerOptionConverter.php', |
|
| 88 | - 'Payone_Log4php_LoggerPatternParser' => '/LoggerPatternParser.php', |
|
| 89 | - 'Payone_Log4php_LoggerUtils' => '/LoggerUtils.php', |
|
| 85 | + // Helpers |
|
| 86 | + 'Payone_Log4php_LoggerFormattingInfo' => '/LoggerFormattingInfo.php', |
|
| 87 | + 'Payone_Log4php_LoggerOptionConverter' => '/LoggerOptionConverter.php', |
|
| 88 | + 'Payone_Log4php_LoggerPatternParser' => '/LoggerPatternParser.php', |
|
| 89 | + 'Payone_Log4php_LoggerUtils' => '/LoggerUtils.php', |
|
| 90 | 90 | |
| 91 | - // Pattern converters |
|
| 92 | - 'Payone_Log4php_LoggerPatternConverter' => '/LoggerPatternConverter.php', |
|
| 93 | - 'Payone_Log4php_LoggerPatternConverterClass' => '/LoggerPatternConverterClass.php', |
|
| 94 | - 'Payone_Log4php_LoggerPatternConverterCookie' => '/LoggerPatternConverterCookie.php', |
|
| 95 | - 'Payone_Log4php_LoggerPatternConverterDate' => '/LoggerPatternConverterDate.php', |
|
| 96 | - 'Payone_Log4php_LoggerPatternConverterEnvironment' => '/LoggerPatternConverterEnvironment.php', |
|
| 97 | - 'Payone_Log4php_LoggerPatternConverterFile' => '/LoggerPatternConverterFile.php', |
|
| 98 | - 'Payone_Log4php_LoggerPatternConverterLevel' => '/LoggerPatternConverterLevel.php', |
|
| 99 | - 'Payone_Log4php_LoggerPatternConverterLine' => '/LoggerPatternConverterLine.php', |
|
| 100 | - 'Payone_Log4php_LoggerPatternConverterLiteral' => '/LoggerPatternConverterLiteral.php', |
|
| 101 | - 'Payone_Log4php_LoggerPatternConverterLogger' => '/LoggerPatternConverterLogger.php', |
|
| 102 | - 'Payone_Log4php_LoggerPatternConverterMDC' => '/LoggerPatternConverterMDC.php', |
|
| 103 | - 'Payone_Log4php_LoggerPatternConverterMessage' => '/LoggerPatternConverterMessage.php', |
|
| 104 | - 'Payone_Log4php_LoggerPatternConverterMethod' => '/LoggerPatternConverterMethod.php', |
|
| 105 | - 'Payone_Log4php_LoggerPatternConverterNDC' => '/LoggerPatternConverterNDC.php', |
|
| 106 | - 'Payone_Log4php_LoggerPatternConverterNewLine' => '/LoggerPatternConverterNewLine.php', |
|
| 107 | - 'Payone_Log4php_LoggerPatternConverterProcess' => '/LoggerPatternConverterProcess.php', |
|
| 108 | - 'Payone_Log4php_LoggerPatternConverterRelative' => '/LoggerPatternConverterRelative.php', |
|
| 109 | - 'Payone_Log4php_LoggerPatternConverterRequest' => '/LoggerPatternConverterRequest.php', |
|
| 110 | - 'Payone_Log4php_LoggerPatternConverterServer' => '/LoggerPatternConverterServer.php', |
|
| 111 | - 'Payone_Log4php_LoggerPatternConverterSession' => '/LoggerPatternConverterSession.php', |
|
| 112 | - 'Payone_Log4php_LoggerPatternConverterSessionID' => '/LoggerPatternConverterSessionID.php', |
|
| 113 | - 'Payone_Log4php_LoggerPatternConverterSuperglobal' => '/LoggerPatternConverterSuperglobal.php', |
|
| 114 | - 'Payone_Log4php_LoggerPatternConverterThrowable' => '/LoggerPatternConverterThrowable.php', |
|
| 91 | + // Pattern converters |
|
| 92 | + 'Payone_Log4php_LoggerPatternConverter' => '/LoggerPatternConverter.php', |
|
| 93 | + 'Payone_Log4php_LoggerPatternConverterClass' => '/LoggerPatternConverterClass.php', |
|
| 94 | + 'Payone_Log4php_LoggerPatternConverterCookie' => '/LoggerPatternConverterCookie.php', |
|
| 95 | + 'Payone_Log4php_LoggerPatternConverterDate' => '/LoggerPatternConverterDate.php', |
|
| 96 | + 'Payone_Log4php_LoggerPatternConverterEnvironment' => '/LoggerPatternConverterEnvironment.php', |
|
| 97 | + 'Payone_Log4php_LoggerPatternConverterFile' => '/LoggerPatternConverterFile.php', |
|
| 98 | + 'Payone_Log4php_LoggerPatternConverterLevel' => '/LoggerPatternConverterLevel.php', |
|
| 99 | + 'Payone_Log4php_LoggerPatternConverterLine' => '/LoggerPatternConverterLine.php', |
|
| 100 | + 'Payone_Log4php_LoggerPatternConverterLiteral' => '/LoggerPatternConverterLiteral.php', |
|
| 101 | + 'Payone_Log4php_LoggerPatternConverterLogger' => '/LoggerPatternConverterLogger.php', |
|
| 102 | + 'Payone_Log4php_LoggerPatternConverterMDC' => '/LoggerPatternConverterMDC.php', |
|
| 103 | + 'Payone_Log4php_LoggerPatternConverterMessage' => '/LoggerPatternConverterMessage.php', |
|
| 104 | + 'Payone_Log4php_LoggerPatternConverterMethod' => '/LoggerPatternConverterMethod.php', |
|
| 105 | + 'Payone_Log4php_LoggerPatternConverterNDC' => '/LoggerPatternConverterNDC.php', |
|
| 106 | + 'Payone_Log4php_LoggerPatternConverterNewLine' => '/LoggerPatternConverterNewLine.php', |
|
| 107 | + 'Payone_Log4php_LoggerPatternConverterProcess' => '/LoggerPatternConverterProcess.php', |
|
| 108 | + 'Payone_Log4php_LoggerPatternConverterRelative' => '/LoggerPatternConverterRelative.php', |
|
| 109 | + 'Payone_Log4php_LoggerPatternConverterRequest' => '/LoggerPatternConverterRequest.php', |
|
| 110 | + 'Payone_Log4php_LoggerPatternConverterServer' => '/LoggerPatternConverterServer.php', |
|
| 111 | + 'Payone_Log4php_LoggerPatternConverterSession' => '/LoggerPatternConverterSession.php', |
|
| 112 | + 'Payone_Log4php_LoggerPatternConverterSessionID' => '/LoggerPatternConverterSessionID.php', |
|
| 113 | + 'Payone_Log4php_LoggerPatternConverterSuperglobal' => '/LoggerPatternConverterSuperglobal.php', |
|
| 114 | + 'Payone_Log4php_LoggerPatternConverterThrowable' => '/LoggerPatternConverterThrowable.php', |
|
| 115 | 115 | |
| 116 | - // Layouts |
|
| 117 | - 'Payone_Log4php_LoggerLayoutHtml' => '/LoggerLayoutHtml.php', |
|
| 118 | - 'Payone_Log4php_LoggerLayoutPattern' => '/LoggerLayoutPattern.php', |
|
| 119 | - 'Payone_Log4php_LoggerLayoutSerialized' => '/LoggerLayoutSerialized.php', |
|
| 120 | - 'Payone_Log4php_LoggerLayoutSimple' => '/LoggerLayoutSimple.php', |
|
| 121 | - 'Payone_Log4php_LoggerLayoutTTCC' => '/LoggerLayoutTTCC.php', |
|
| 122 | - 'Payone_Log4php_LoggerLayoutXml' => '/LoggerLayoutXml.php', |
|
| 116 | + // Layouts |
|
| 117 | + 'Payone_Log4php_LoggerLayoutHtml' => '/LoggerLayoutHtml.php', |
|
| 118 | + 'Payone_Log4php_LoggerLayoutPattern' => '/LoggerLayoutPattern.php', |
|
| 119 | + 'Payone_Log4php_LoggerLayoutSerialized' => '/LoggerLayoutSerialized.php', |
|
| 120 | + 'Payone_Log4php_LoggerLayoutSimple' => '/LoggerLayoutSimple.php', |
|
| 121 | + 'Payone_Log4php_LoggerLayoutTTCC' => '/LoggerLayoutTTCC.php', |
|
| 122 | + 'Payone_Log4php_LoggerLayoutXml' => '/LoggerLayoutXml.php', |
|
| 123 | 123 | |
| 124 | - // Renderers |
|
| 125 | - 'Payone_Log4php_LoggerRendererDefault' => '/LoggerRendererDefault.php', |
|
| 126 | - 'Payone_Log4php_LoggerRendererException' => '/LoggerRendererException.php', |
|
| 127 | - 'Payone_Log4php_LoggerRendererMap' => '/LoggerRendererMap.php', |
|
| 128 | - 'Payone_Log4php_LoggerRendererObject' => '/LoggerRendererObject.php', |
|
| 129 | - ); |
|
| 124 | + // Renderers |
|
| 125 | + 'Payone_Log4php_LoggerRendererDefault' => '/LoggerRendererDefault.php', |
|
| 126 | + 'Payone_Log4php_LoggerRendererException' => '/LoggerRendererException.php', |
|
| 127 | + 'Payone_Log4php_LoggerRendererMap' => '/LoggerRendererMap.php', |
|
| 128 | + 'Payone_Log4php_LoggerRendererObject' => '/LoggerRendererObject.php', |
|
| 129 | + ); |
|
| 130 | 130 | |
| 131 | - /** |
|
| 132 | - * Loads a class. |
|
| 133 | - * @param string $className The name of the class to load. |
|
| 134 | - */ |
|
| 135 | - public static function autoload($className) { |
|
| 136 | - if(isset(self::$classes[$className])) { |
|
| 137 | - require_once dirname(__FILE__) . self::$classes[$className]; |
|
| 138 | - } |
|
| 139 | - } |
|
| 131 | + /** |
|
| 132 | + * Loads a class. |
|
| 133 | + * @param string $className The name of the class to load. |
|
| 134 | + */ |
|
| 135 | + public static function autoload($className) { |
|
| 136 | + if(isset(self::$classes[$className])) { |
|
| 137 | + require_once dirname(__FILE__) . self::$classes[$className]; |
|
| 138 | + } |
|
| 139 | + } |
|
| 140 | 140 | } |