Passed
Push — 1.10.x ( aae6b1...e5a590 )
by Yannick
131:05 queued 81:36
created
main/inc/lib/phpdocx/lib/log4php/helpers/LoggerPatternParser.php 1 patch
Indentation   +301 added lines, -301 removed lines patch added patch discarded remove patch
@@ -1,22 +1,22 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * Licensed to the Apache Software Foundation (ASF) under one or more
4
- * contributor license agreements. See the NOTICE file distributed with
5
- * this work for additional information regarding copyright ownership.
6
- * The ASF licenses this file to You under the Apache License, Version 2.0
7
- * (the "License"); you may not use this file except in compliance with
8
- * the License. You may obtain a copy of the License at
9
- *
10
- *	   http://www.apache.org/licenses/LICENSE-2.0
11
- *
12
- * Unless required by applicable law or agreed to in writing, software
13
- * distributed under the License is distributed on an "AS IS" BASIS,
14
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
- * See the License for the specific language governing permissions and
16
- * limitations under the License.
17
- *
18
- * @package log4php
19
- */
3
+     * Licensed to the Apache Software Foundation (ASF) under one or more
4
+     * contributor license agreements. See the NOTICE file distributed with
5
+     * this work for additional information regarding copyright ownership.
6
+     * The ASF licenses this file to You under the Apache License, Version 2.0
7
+     * (the "License"); you may not use this file except in compliance with
8
+     * the License. You may obtain a copy of the License at
9
+     *
10
+     *	   http://www.apache.org/licenses/LICENSE-2.0
11
+     *
12
+     * Unless required by applicable law or agreed to in writing, software
13
+     * distributed under the License is distributed on an "AS IS" BASIS,
14
+     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+     * See the License for the specific language governing permissions and
16
+     * limitations under the License.
17
+     *
18
+     * @package log4php
19
+     */
20 20
 
21 21
 /**
22 22
  * Most of the work of the {@link LoggerPatternLayout} class 
@@ -33,309 +33,309 @@  discard block
 block discarded – undo
33 33
  */
34 34
 class LoggerPatternParser {
35 35
 
36
-	const ESCAPE_CHAR = '%';
36
+    const ESCAPE_CHAR = '%';
37 37
 	
38
-	const LITERAL_STATE = 0;
39
-	const CONVERTER_STATE = 1;
40
-	const MINUS_STATE = 2;
41
-	const DOT_STATE = 3;
42
-	const MIN_STATE = 4;
43
-	const MAX_STATE = 5;
38
+    const LITERAL_STATE = 0;
39
+    const CONVERTER_STATE = 1;
40
+    const MINUS_STATE = 2;
41
+    const DOT_STATE = 3;
42
+    const MIN_STATE = 4;
43
+    const MAX_STATE = 5;
44 44
 	
45
-	const FULL_LOCATION_CONVERTER = 1000;
46
-	const METHOD_LOCATION_CONVERTER = 1001;
47
-	const CLASS_LOCATION_CONVERTER = 1002;
48
-	const FILE_LOCATION_CONVERTER = 1003;
49
-	const LINE_LOCATION_CONVERTER = 1004;
45
+    const FULL_LOCATION_CONVERTER = 1000;
46
+    const METHOD_LOCATION_CONVERTER = 1001;
47
+    const CLASS_LOCATION_CONVERTER = 1002;
48
+    const FILE_LOCATION_CONVERTER = 1003;
49
+    const LINE_LOCATION_CONVERTER = 1004;
50 50
 	
51
-	const RELATIVE_TIME_CONVERTER = 2000;
52
-	const THREAD_CONVERTER = 2001;
53
-	const LEVEL_CONVERTER = 2002;
54
-	const NDC_CONVERTER = 2003;
55
-	const MESSAGE_CONVERTER = 2004;
51
+    const RELATIVE_TIME_CONVERTER = 2000;
52
+    const THREAD_CONVERTER = 2001;
53
+    const LEVEL_CONVERTER = 2002;
54
+    const NDC_CONVERTER = 2003;
55
+    const MESSAGE_CONVERTER = 2004;
56 56
 	
57
-	const DATE_FORMAT_ISO8601 = 'Y-m-d H:i:s,u'; 
58
-	const DATE_FORMAT_ABSOLUTE = 'H:i:s';
59
-	const DATE_FORMAT_DATE = 'd M Y H:i:s,u';
57
+    const DATE_FORMAT_ISO8601 = 'Y-m-d H:i:s,u'; 
58
+    const DATE_FORMAT_ABSOLUTE = 'H:i:s';
59
+    const DATE_FORMAT_DATE = 'd M Y H:i:s,u';
60 60
 
61
-	private $state;
62
-	private $currentLiteral;
63
-	private $patternLength;
64
-	private $i;
61
+    private $state;
62
+    private $currentLiteral;
63
+    private $patternLength;
64
+    private $i;
65 65
 	
66
-	/**
67
-	 * @var LoggerPatternConverter
68
-	 */
69
-	private $head = null;
66
+    /**
67
+     * @var LoggerPatternConverter
68
+     */
69
+    private $head = null;
70 70
 	 
71
-	/**
72
-	 * @var LoggerPatternConverter
73
-	 */
74
-	private $tail = null;
71
+    /**
72
+     * @var LoggerPatternConverter
73
+     */
74
+    private $tail = null;
75 75
 	
76
-	/**
77
-	 * @var LoggerFormattingInfo
78
-	 */
79
-	private $formattingInfo;
76
+    /**
77
+     * @var LoggerFormattingInfo
78
+     */
79
+    private $formattingInfo;
80 80
 	
81
-	/**
82
-	 * @var string pattern to parse
83
-	 */
84
-	private $pattern;
81
+    /**
82
+     * @var string pattern to parse
83
+     */
84
+    private $pattern;
85 85
 
86
-	/**
87
-	 * Constructor 
88
-	 *
89
-	 * @param string $pattern
90
-	 */
91
-	public function __construct($pattern) {
92
-		$this->pattern = $pattern;
93
-		$this->patternLength =	strlen($pattern);
94
-		$this->formattingInfo = new LoggerFormattingInfo();
95
-		$this->state = self::LITERAL_STATE;
96
-	}
86
+    /**
87
+     * Constructor 
88
+     *
89
+     * @param string $pattern
90
+     */
91
+    public function __construct($pattern) {
92
+        $this->pattern = $pattern;
93
+        $this->patternLength =	strlen($pattern);
94
+        $this->formattingInfo = new LoggerFormattingInfo();
95
+        $this->state = self::LITERAL_STATE;
96
+    }
97 97
 
98
-	/**
99
-	 * @param LoggerPatternConverter $pc
100
-	 */
101
-	public function addToList($pc) {
102
-		if($this->head == null) {
103
-			$this->head = $pc;
104
-			$this->tail = $this->head;
105
-		} else {
106
-			$this->tail->next = $pc;
107
-			$this->tail = $this->tail->next;
108
-		}
109
-	}
98
+    /**
99
+     * @param LoggerPatternConverter $pc
100
+     */
101
+    public function addToList($pc) {
102
+        if($this->head == null) {
103
+            $this->head = $pc;
104
+            $this->tail = $this->head;
105
+        } else {
106
+            $this->tail->next = $pc;
107
+            $this->tail = $this->tail->next;
108
+        }
109
+    }
110 110
 
111
-	/**
112
-	 * @return string
113
-	 */
114
-	public function extractOption() {
115
-		if(($this->i < $this->patternLength) and ($this->pattern{$this->i} == '{')) {
116
-			$end = strpos($this->pattern, '}' , $this->i);
117
-			if($end !== false) {
118
-				$r = substr($this->pattern, ($this->i + 1), ($end - $this->i - 1));
119
-				$this->i= $end + 1;
120
-				return $r;
121
-			}
122
-		}
123
-		return null;
124
-	}
111
+    /**
112
+     * @return string
113
+     */
114
+    public function extractOption() {
115
+        if(($this->i < $this->patternLength) and ($this->pattern{$this->i} == '{')) {
116
+            $end = strpos($this->pattern, '}' , $this->i);
117
+            if($end !== false) {
118
+                $r = substr($this->pattern, ($this->i + 1), ($end - $this->i - 1));
119
+                $this->i= $end + 1;
120
+                return $r;
121
+            }
122
+        }
123
+        return null;
124
+    }
125 125
 
126
-	/**
127
-	 * The option is expected to be in decimal and positive. In case of
128
-	 * error, zero is returned.	 
129
-	 */
130
-	public function extractPrecisionOption() {
131
-		$opt = $this->extractOption();
132
-		$r = 0;
133
-		if($opt !== null) {
134
-			if(is_numeric($opt)) {
135
-				$r = (int)$opt;
136
-				if($r <= 0) {
137
-					$r = 0;
138
-				}
139
-			}
140
-		}
141
-		return $r;
142
-	}
126
+    /**
127
+     * The option is expected to be in decimal and positive. In case of
128
+     * error, zero is returned.	 
129
+     */
130
+    public function extractPrecisionOption() {
131
+        $opt = $this->extractOption();
132
+        $r = 0;
133
+        if($opt !== null) {
134
+            if(is_numeric($opt)) {
135
+                $r = (int)$opt;
136
+                if($r <= 0) {
137
+                    $r = 0;
138
+                }
139
+            }
140
+        }
141
+        return $r;
142
+    }
143 143
 
144 144
 	
145
-	/** Parser.
146
-	 * 
147
-	 * @return LoggerPatternConverter Returns $this->head.
148
-	 */
149
-	public function parse() {
150
-		$c = '';
151
-		$this->i = 0;
152
-		$this->currentLiteral = '';
153
-		while($this->i < $this->patternLength) {
154
-			$c = $this->pattern{$this->i++};
145
+    /** Parser.
146
+     * 
147
+     * @return LoggerPatternConverter Returns $this->head.
148
+     */
149
+    public function parse() {
150
+        $c = '';
151
+        $this->i = 0;
152
+        $this->currentLiteral = '';
153
+        while($this->i < $this->patternLength) {
154
+            $c = $this->pattern{$this->i++};
155 155
 
156
-			switch($this->state) {
157
-				case self::LITERAL_STATE:
158
-					// In literal state, the last char is always a literal.
159
-					if($this->i == $this->patternLength) {
160
-						$this->currentLiteral .= $c;
161
-						continue;
162
-					}
163
-					if($c == self::ESCAPE_CHAR) {
164
-						// peek at the next char.
165
-						switch($this->pattern{$this->i}) {
166
-							case self::ESCAPE_CHAR:
167
-								$this->currentLiteral .= $c;
168
-								$this->i++; // move pointer
169
-								break;
170
-							case 'n':
171
-								$this->currentLiteral .= PHP_EOL;
172
-								$this->i++; // move pointer
173
-								break;
174
-							default:
175
-								if(strlen($this->currentLiteral) != 0) {
176
-									$this->addToList(new LoggerLiteralPatternConverter($this->currentLiteral));
177
-								}
178
-								$this->currentLiteral = $c;
179
-								$this->state = self::CONVERTER_STATE;
180
-								$this->formattingInfo->reset();
181
-						}
182
-					} else {
183
-						$this->currentLiteral .= $c;
184
-					}
185
-					break;
186
-				case self::CONVERTER_STATE:
187
-						$this->currentLiteral .= $c;
188
-						switch($c) {
189
-						case '-':
190
-							$this->formattingInfo->leftAlign = true;
191
-							break;
192
-						case '.':
193
-							$this->state = self::DOT_STATE;
194
-								break;
195
-						default:
196
-							if(ord($c) >= ord('0') and ord($c) <= ord('9')) {
197
-								$this->formattingInfo->min = ord($c) - ord('0');
198
-								$this->state = self::MIN_STATE;
199
-							} else {
200
-								$this->finalizeConverter($c);
201
-							}
202
-						} // switch
203
-					break;
204
-				case self::MIN_STATE:
205
-					$this->currentLiteral .= $c;
206
-					if(ord($c) >= ord('0') and ord($c) <= ord('9')) {
207
-						$this->formattingInfo->min = ($this->formattingInfo->min * 10) + (ord($c) - ord('0'));
208
-					} else if ($c == '.') {
209
-						$this->state = self::DOT_STATE;
210
-					} else {
211
-						$this->finalizeConverter($c);
212
-					}
213
-					break;
214
-				case self::DOT_STATE:
215
-					$this->currentLiteral .= $c;
216
-					if(ord($c) >= ord('0') and ord($c) <= ord('9')) {
217
-						$this->formattingInfo->max = ord($c) - ord('0');
218
-						$this->state = self::MAX_STATE;
219
-					} else {
220
-						$this->state = self::LITERAL_STATE;
221
-					}
222
-					break;
223
-				case self::MAX_STATE:
224
-					$this->currentLiteral .= $c;
225
-					if(ord($c) >= ord('0') and ord($c) <= ord('9')) {
226
-						$this->formattingInfo->max = ($this->formattingInfo->max * 10) + (ord($c) - ord('0'));
227
-					} else {
228
-						$this->finalizeConverter($c);
229
-						$this->state = self::LITERAL_STATE;
230
-					}
231
-					break;
232
-			} // switch
233
-		} // while
234
-		if(strlen($this->currentLiteral) != 0) {
235
-			$this->addToList(new LoggerLiteralPatternConverter($this->currentLiteral));
236
-		}
237
-		return $this->head;
238
-	}
156
+            switch($this->state) {
157
+                case self::LITERAL_STATE:
158
+                    // In literal state, the last char is always a literal.
159
+                    if($this->i == $this->patternLength) {
160
+                        $this->currentLiteral .= $c;
161
+                        continue;
162
+                    }
163
+                    if($c == self::ESCAPE_CHAR) {
164
+                        // peek at the next char.
165
+                        switch($this->pattern{$this->i}) {
166
+                            case self::ESCAPE_CHAR:
167
+                                $this->currentLiteral .= $c;
168
+                                $this->i++; // move pointer
169
+                                break;
170
+                            case 'n':
171
+                                $this->currentLiteral .= PHP_EOL;
172
+                                $this->i++; // move pointer
173
+                                break;
174
+                            default:
175
+                                if(strlen($this->currentLiteral) != 0) {
176
+                                    $this->addToList(new LoggerLiteralPatternConverter($this->currentLiteral));
177
+                                }
178
+                                $this->currentLiteral = $c;
179
+                                $this->state = self::CONVERTER_STATE;
180
+                                $this->formattingInfo->reset();
181
+                        }
182
+                    } else {
183
+                        $this->currentLiteral .= $c;
184
+                    }
185
+                    break;
186
+                case self::CONVERTER_STATE:
187
+                        $this->currentLiteral .= $c;
188
+                        switch($c) {
189
+                        case '-':
190
+                            $this->formattingInfo->leftAlign = true;
191
+                            break;
192
+                        case '.':
193
+                            $this->state = self::DOT_STATE;
194
+                                break;
195
+                        default:
196
+                            if(ord($c) >= ord('0') and ord($c) <= ord('9')) {
197
+                                $this->formattingInfo->min = ord($c) - ord('0');
198
+                                $this->state = self::MIN_STATE;
199
+                            } else {
200
+                                $this->finalizeConverter($c);
201
+                            }
202
+                        } // switch
203
+                    break;
204
+                case self::MIN_STATE:
205
+                    $this->currentLiteral .= $c;
206
+                    if(ord($c) >= ord('0') and ord($c) <= ord('9')) {
207
+                        $this->formattingInfo->min = ($this->formattingInfo->min * 10) + (ord($c) - ord('0'));
208
+                    } else if ($c == '.') {
209
+                        $this->state = self::DOT_STATE;
210
+                    } else {
211
+                        $this->finalizeConverter($c);
212
+                    }
213
+                    break;
214
+                case self::DOT_STATE:
215
+                    $this->currentLiteral .= $c;
216
+                    if(ord($c) >= ord('0') and ord($c) <= ord('9')) {
217
+                        $this->formattingInfo->max = ord($c) - ord('0');
218
+                        $this->state = self::MAX_STATE;
219
+                    } else {
220
+                        $this->state = self::LITERAL_STATE;
221
+                    }
222
+                    break;
223
+                case self::MAX_STATE:
224
+                    $this->currentLiteral .= $c;
225
+                    if(ord($c) >= ord('0') and ord($c) <= ord('9')) {
226
+                        $this->formattingInfo->max = ($this->formattingInfo->max * 10) + (ord($c) - ord('0'));
227
+                    } else {
228
+                        $this->finalizeConverter($c);
229
+                        $this->state = self::LITERAL_STATE;
230
+                    }
231
+                    break;
232
+            } // switch
233
+        } // while
234
+        if(strlen($this->currentLiteral) != 0) {
235
+            $this->addToList(new LoggerLiteralPatternConverter($this->currentLiteral));
236
+        }
237
+        return $this->head;
238
+    }
239 239
 
240
-	public function finalizeConverter($c) {
241
-		$pc = null;
242
-		switch($c) {
243
-			case 'c':
244
-				$pc = new LoggerCategoryPatternConverter($this->formattingInfo, $this->extractPrecisionOption());
245
-				$this->currentLiteral = '';
246
-				break;
247
-			case 'C':
248
-				$pc = new LoggerClassNamePatternConverter($this->formattingInfo, $this->extractPrecisionOption());
249
-				$this->currentLiteral = '';
250
-				break;
251
-			case 'd':
252
-				$dateFormatStr = self::DATE_FORMAT_ISO8601; // ISO8601_DATE_FORMAT;
253
-				$dOpt = $this->extractOption();
240
+    public function finalizeConverter($c) {
241
+        $pc = null;
242
+        switch($c) {
243
+            case 'c':
244
+                $pc = new LoggerCategoryPatternConverter($this->formattingInfo, $this->extractPrecisionOption());
245
+                $this->currentLiteral = '';
246
+                break;
247
+            case 'C':
248
+                $pc = new LoggerClassNamePatternConverter($this->formattingInfo, $this->extractPrecisionOption());
249
+                $this->currentLiteral = '';
250
+                break;
251
+            case 'd':
252
+                $dateFormatStr = self::DATE_FORMAT_ISO8601; // ISO8601_DATE_FORMAT;
253
+                $dOpt = $this->extractOption();
254 254
 
255
-				if($dOpt !== null)
256
-					$dateFormatStr = $dOpt;
255
+                if($dOpt !== null)
256
+                    $dateFormatStr = $dOpt;
257 257
 					
258
-				if($dateFormatStr == 'ISO8601') {
259
-					$df = self::DATE_FORMAT_ISO8601;
260
-				} else if($dateFormatStr == 'ABSOLUTE') {
261
-					$df = self::DATE_FORMAT_ABSOLUTE;
262
-				} else if($dateFormatStr == 'DATE') {
263
-					$df = self::DATE_FORMAT_DATE;
264
-				} else {
265
-					$df = $dateFormatStr;
266
-					if($df == null) {
267
-						$df = self::DATE_FORMAT_ISO8601;
268
-					}
269
-				}
270
-				$pc = new LoggerDatePatternConverter($this->formattingInfo, $df);
271
-				$this->currentLiteral = '';
272
-				break;
273
-			case 'F':
274
-				$pc = new LoggerLocationPatternConverter($this->formattingInfo, self::FILE_LOCATION_CONVERTER);
275
-				$this->currentLiteral = '';
276
-				break;
277
-			case 'l':
278
-				$pc = new LoggerLocationPatternConverter($this->formattingInfo, self::FULL_LOCATION_CONVERTER);
279
-				$this->currentLiteral = '';
280
-				break;
281
-			case 'L':
282
-				$pc = new LoggerLocationPatternConverter($this->formattingInfo, self::LINE_LOCATION_CONVERTER);
283
-				$this->currentLiteral = '';
284
-				break;
285
-			case 'm':
286
-				$pc = new LoggerBasicPatternConverter($this->formattingInfo, self::MESSAGE_CONVERTER);
287
-				$this->currentLiteral = '';
288
-				break;
289
-			case 'M':
290
-				$pc = new LoggerLocationPatternConverter($this->formattingInfo, self::METHOD_LOCATION_CONVERTER);
291
-				$this->currentLiteral = '';
292
-				break;
293
-			case 'p':
294
-				$pc = new LoggerBasicPatternConverter($this->formattingInfo, self::LEVEL_CONVERTER);
295
-				$this->currentLiteral = '';
296
-				break;
297
-			case 'r':
298
-				$pc = new LoggerBasicPatternConverter($this->formattingInfo, self::RELATIVE_TIME_CONVERTER);
299
-				$this->currentLiteral = '';
300
-				break;
301
-			case 't':
302
-				$pc = new LoggerBasicPatternConverter($this->formattingInfo, self::THREAD_CONVERTER);
303
-				$this->currentLiteral = '';
304
-				break;
305
-			case 'u':
306
-				if($this->i < $this->patternLength) {
307
-					$cNext = $this->pattern{$this->i};
308
-					if(ord($cNext) >= ord('0') and ord($cNext) <= ord('9')) {
309
-						$pc = new LoggerUserFieldPatternConverter($this->formattingInfo, (string)(ord($cNext) - ord('0')));
310
-						$this->currentLiteral = '';
311
-						$this->i++;
312
-					}
313
-				}
314
-				break;
315
-			case 'x':
316
-				$pc = new LoggerBasicPatternConverter($this->formattingInfo, self::NDC_CONVERTER);
317
-				$this->currentLiteral = '';
318
-				break;
319
-			case 'X':
320
-				$xOpt = $this->extractOption();
321
-				$pc = new LoggerMDCPatternConverter($this->formattingInfo, $xOpt);
322
-				$this->currentLiteral = '';
323
-				break;
324
-			default:
325
-				$pc = new LoggerLiteralPatternConverter($this->currentLiteral);
326
-				$this->currentLiteral = '';
327
-		}
328
-		$this->addConverter($pc);
329
-	}
258
+                if($dateFormatStr == 'ISO8601') {
259
+                    $df = self::DATE_FORMAT_ISO8601;
260
+                } else if($dateFormatStr == 'ABSOLUTE') {
261
+                    $df = self::DATE_FORMAT_ABSOLUTE;
262
+                } else if($dateFormatStr == 'DATE') {
263
+                    $df = self::DATE_FORMAT_DATE;
264
+                } else {
265
+                    $df = $dateFormatStr;
266
+                    if($df == null) {
267
+                        $df = self::DATE_FORMAT_ISO8601;
268
+                    }
269
+                }
270
+                $pc = new LoggerDatePatternConverter($this->formattingInfo, $df);
271
+                $this->currentLiteral = '';
272
+                break;
273
+            case 'F':
274
+                $pc = new LoggerLocationPatternConverter($this->formattingInfo, self::FILE_LOCATION_CONVERTER);
275
+                $this->currentLiteral = '';
276
+                break;
277
+            case 'l':
278
+                $pc = new LoggerLocationPatternConverter($this->formattingInfo, self::FULL_LOCATION_CONVERTER);
279
+                $this->currentLiteral = '';
280
+                break;
281
+            case 'L':
282
+                $pc = new LoggerLocationPatternConverter($this->formattingInfo, self::LINE_LOCATION_CONVERTER);
283
+                $this->currentLiteral = '';
284
+                break;
285
+            case 'm':
286
+                $pc = new LoggerBasicPatternConverter($this->formattingInfo, self::MESSAGE_CONVERTER);
287
+                $this->currentLiteral = '';
288
+                break;
289
+            case 'M':
290
+                $pc = new LoggerLocationPatternConverter($this->formattingInfo, self::METHOD_LOCATION_CONVERTER);
291
+                $this->currentLiteral = '';
292
+                break;
293
+            case 'p':
294
+                $pc = new LoggerBasicPatternConverter($this->formattingInfo, self::LEVEL_CONVERTER);
295
+                $this->currentLiteral = '';
296
+                break;
297
+            case 'r':
298
+                $pc = new LoggerBasicPatternConverter($this->formattingInfo, self::RELATIVE_TIME_CONVERTER);
299
+                $this->currentLiteral = '';
300
+                break;
301
+            case 't':
302
+                $pc = new LoggerBasicPatternConverter($this->formattingInfo, self::THREAD_CONVERTER);
303
+                $this->currentLiteral = '';
304
+                break;
305
+            case 'u':
306
+                if($this->i < $this->patternLength) {
307
+                    $cNext = $this->pattern{$this->i};
308
+                    if(ord($cNext) >= ord('0') and ord($cNext) <= ord('9')) {
309
+                        $pc = new LoggerUserFieldPatternConverter($this->formattingInfo, (string)(ord($cNext) - ord('0')));
310
+                        $this->currentLiteral = '';
311
+                        $this->i++;
312
+                    }
313
+                }
314
+                break;
315
+            case 'x':
316
+                $pc = new LoggerBasicPatternConverter($this->formattingInfo, self::NDC_CONVERTER);
317
+                $this->currentLiteral = '';
318
+                break;
319
+            case 'X':
320
+                $xOpt = $this->extractOption();
321
+                $pc = new LoggerMDCPatternConverter($this->formattingInfo, $xOpt);
322
+                $this->currentLiteral = '';
323
+                break;
324
+            default:
325
+                $pc = new LoggerLiteralPatternConverter($this->currentLiteral);
326
+                $this->currentLiteral = '';
327
+        }
328
+        $this->addConverter($pc);
329
+    }
330 330
 
331
-	public function addConverter($pc) {
332
-		$this->currentLiteral = '';
333
-		// Add the pattern converter to the list.
334
-		$this->addToList($pc);
335
-		// Next pattern is assumed to be a literal.
336
-		$this->state = self::LITERAL_STATE;
337
-		// Reset formatting info
338
-		$this->formattingInfo->reset();
339
-	}
331
+    public function addConverter($pc) {
332
+        $this->currentLiteral = '';
333
+        // Add the pattern converter to the list.
334
+        $this->addToList($pc);
335
+        // Next pattern is assumed to be a literal.
336
+        $this->state = self::LITERAL_STATE;
337
+        // Reset formatting info
338
+        $this->formattingInfo->reset();
339
+    }
340 340
 }
341 341
 
Please login to merge, or discard this patch.
main/inc/lib/phpdocx/lib/log4php/helpers/LoggerBasicPatternConverter.php 1 patch
Indentation   +37 added lines, -37 removed lines patch added patch discarded remove patch
@@ -24,48 +24,48 @@
 block discarded – undo
24 24
  */
25 25
 class LoggerBasicPatternConverter extends LoggerPatternConverter {
26 26
 
27
-	/**
28
-	 * @var integer
29
-	 */
30
-	private $type;
27
+    /**
28
+     * @var integer
29
+     */
30
+    private $type;
31 31
 
32
-	/**
33
-	 * Constructor
34
-	 *
35
-	 * @param string $formattingInfo
36
-	 * @param integer $type
37
-	 */
38
-	public function __construct($formattingInfo, $type) {
39
-	  parent::__construct($formattingInfo);
40
-	  $this->type = $type;
41
-	}
32
+    /**
33
+     * Constructor
34
+     *
35
+     * @param string $formattingInfo
36
+     * @param integer $type
37
+     */
38
+    public function __construct($formattingInfo, $type) {
39
+        parent::__construct($formattingInfo);
40
+        $this->type = $type;
41
+    }
42 42
 
43
-	/**
44
-	 * @param LoggerLoggingEvent $event
45
-	 * @return string
46
-	 */
47
-	public function convert($event) {
48
-		switch($this->type) {
49
-			case LoggerPatternParser::RELATIVE_TIME_CONVERTER:
50
-				$timeStamp = $event->getTimeStamp();
51
-				$startTime = LoggerLoggingEvent::getStartTime();
52
-				return (string)(int)($timeStamp * 1000 - $startTime * 1000);
43
+    /**
44
+     * @param LoggerLoggingEvent $event
45
+     * @return string
46
+     */
47
+    public function convert($event) {
48
+        switch($this->type) {
49
+            case LoggerPatternParser::RELATIVE_TIME_CONVERTER:
50
+                $timeStamp = $event->getTimeStamp();
51
+                $startTime = LoggerLoggingEvent::getStartTime();
52
+                return (string)(int)($timeStamp * 1000 - $startTime * 1000);
53 53
 				
54
-			case LoggerPatternParser::THREAD_CONVERTER:
55
-				return $event->getThreadName();
54
+            case LoggerPatternParser::THREAD_CONVERTER:
55
+                return $event->getThreadName();
56 56
 
57
-			case LoggerPatternParser::LEVEL_CONVERTER:
58
-				$level = $event->getLevel();
59
-				return $level->toString();
57
+            case LoggerPatternParser::LEVEL_CONVERTER:
58
+                $level = $event->getLevel();
59
+                return $level->toString();
60 60
 
61
-			case LoggerPatternParser::NDC_CONVERTER:
62
-				return $event->getNDC();
61
+            case LoggerPatternParser::NDC_CONVERTER:
62
+                return $event->getNDC();
63 63
 
64
-			case LoggerPatternParser::MESSAGE_CONVERTER:
65
-				return $event->getRenderedMessage();
64
+            case LoggerPatternParser::MESSAGE_CONVERTER:
65
+                return $event->getRenderedMessage();
66 66
 				
67
-			default: 
68
-				return '';
69
-		}
70
-	}
67
+            default: 
68
+                return '';
69
+        }
70
+    }
71 71
 }
Please login to merge, or discard this patch.
main/inc/lib/phpdocx/lib/log4php/helpers/LoggerOptionConverter.php 1 patch
Indentation   +269 added lines, -269 removed lines patch added patch discarded remove patch
@@ -1,22 +1,22 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * Licensed to the Apache Software Foundation (ASF) under one or more
4
- * contributor license agreements. See the NOTICE file distributed with
5
- * this work for additional information regarding copyright ownership.
6
- * The ASF licenses this file to You under the Apache License, Version 2.0
7
- * (the "License"); you may not use this file except in compliance with
8
- * the License. You may obtain a copy of the License at
9
- *
10
- *	   http://www.apache.org/licenses/LICENSE-2.0
11
- *
12
- * Unless required by applicable law or agreed to in writing, software
13
- * distributed under the License is distributed on an "AS IS" BASIS,
14
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
- * See the License for the specific language governing permissions and
16
- * limitations under the License.
17
- *
18
- * @package log4php
19
- */
3
+     * Licensed to the Apache Software Foundation (ASF) under one or more
4
+     * contributor license agreements. See the NOTICE file distributed with
5
+     * this work for additional information regarding copyright ownership.
6
+     * The ASF licenses this file to You under the Apache License, Version 2.0
7
+     * (the "License"); you may not use this file except in compliance with
8
+     * the License. You may obtain a copy of the License at
9
+     *
10
+     *	   http://www.apache.org/licenses/LICENSE-2.0
11
+     *
12
+     * Unless required by applicable law or agreed to in writing, software
13
+     * distributed under the License is distributed on an "AS IS" BASIS,
14
+     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+     * See the License for the specific language governing permissions and
16
+     * limitations under the License.
17
+     *
18
+     * @package log4php
19
+     */
20 20
 
21 21
 /**
22 22
  * A convenience class to convert property values to specific types.
@@ -29,193 +29,193 @@  discard block
 block discarded – undo
29 29
  */
30 30
 class LoggerOptionConverter {
31 31
 
32
-	const DELIM_START = '${';
33
-	const DELIM_STOP = '}';
34
-	const DELIM_START_LEN = 2;
35
-	const DELIM_STOP_LEN = 1;
32
+    const DELIM_START = '${';
33
+    const DELIM_STOP = '}';
34
+    const DELIM_START_LEN = 2;
35
+    const DELIM_STOP_LEN = 1;
36 36
 
37
-   /**
38
-	* Read a predefined var.
39
-	*
40
-	* It returns a value referenced by <var>$key</var> using this search criteria:
41
-	* - if <var>$key</var> is a constant then return it. Else
42
-	* - if <var>$key</var> is set in <var>$_ENV</var> then return it. Else
43
-	* - return <var>$def</var>. 
44
-	*
45
-	* @param string $key The key to search for.
46
-	* @param string $def The default value to return.
47
-	* @return string	the string value of the system property, or the default
48
-	*					value if there is no property with that key.
49
-	*
50
-	* @static
51
-	*/
52
-	public static function getSystemProperty($key, $def) {
53
-		if(defined($key)) {
54
-			return (string)constant($key);
55
-		} else if(isset($_SERVER[$key])) {
56
-			return (string)$_SERVER[$key];
57
-		} else if(isset($_ENV[$key])) {
58
-			return (string)$_ENV[$key];
59
-		} else {
60
-			return $def;
61
-		}
62
-	}
37
+    /**
38
+     * Read a predefined var.
39
+     *
40
+     * It returns a value referenced by <var>$key</var> using this search criteria:
41
+     * - if <var>$key</var> is a constant then return it. Else
42
+     * - if <var>$key</var> is set in <var>$_ENV</var> then return it. Else
43
+     * - return <var>$def</var>. 
44
+     *
45
+     * @param string $key The key to search for.
46
+     * @param string $def The default value to return.
47
+     * @return string	the string value of the system property, or the default
48
+     *					value if there is no property with that key.
49
+     *
50
+     * @static
51
+     */
52
+    public static function getSystemProperty($key, $def) {
53
+        if(defined($key)) {
54
+            return (string)constant($key);
55
+        } else if(isset($_SERVER[$key])) {
56
+            return (string)$_SERVER[$key];
57
+        } else if(isset($_ENV[$key])) {
58
+            return (string)$_ENV[$key];
59
+        } else {
60
+            return $def;
61
+        }
62
+    }
63 63
 
64
-	/**
65
-	 * If <var>$value</var> is <i>true</i>, then <i>true</i> is
66
-	 * returned. If <var>$value</var> is <i>false</i>, then
67
-	 * <i>true</i> is returned. Otherwise, <var>$default</var> is
68
-	 * returned.
69
-	 *
70
-	 * <p>Case of value is unimportant.</p>
71
-	 *
72
-	 * @param string $value
73
-	 * @param boolean $default
74
-	 * @return boolean
75
-	 *
76
-	 * @static
77
-	 */
78
-	public static function toBoolean($value, $default=true) {
79
-	    if (is_null($value)) {
80
-			return $default;
81
-	    } elseif (is_string($value)) {
82
-		$trimmedVal = strtolower(trim($value));
64
+    /**
65
+     * If <var>$value</var> is <i>true</i>, then <i>true</i> is
66
+     * returned. If <var>$value</var> is <i>false</i>, then
67
+     * <i>true</i> is returned. Otherwise, <var>$default</var> is
68
+     * returned.
69
+     *
70
+     * <p>Case of value is unimportant.</p>
71
+     *
72
+     * @param string $value
73
+     * @param boolean $default
74
+     * @return boolean
75
+     *
76
+     * @static
77
+     */
78
+    public static function toBoolean($value, $default=true) {
79
+        if (is_null($value)) {
80
+            return $default;
81
+        } elseif (is_string($value)) {
82
+        $trimmedVal = strtolower(trim($value));
83 83
 	
84 84
             if("1" == $trimmedVal or "true" == $trimmedVal or "yes" == $trimmedVal or "on" == $trimmedVal) {
85
-			return true;
85
+            return true;
86 86
             } else if ("" == $trimmedVal or "0" == $trimmedVal or "false" == $trimmedVal or "no" == $trimmedVal or "off" == $trimmedVal) {
87
-			return false;
88
-		}
89
-		} elseif (is_bool($value)) {
90
-		    return $value;
91
-		} elseif (is_int($value)) {
92
-		    return !($value == 0); // true is everything but 0 like in C 
93
-		}
87
+            return false;
88
+        }
89
+        } elseif (is_bool($value)) {
90
+            return $value;
91
+        } elseif (is_int($value)) {
92
+            return !($value == 0); // true is everything but 0 like in C 
93
+        }
94 94
 		
95
-		trigger_error("Could not convert ".var_export($value,1)." to boolean!", E_USER_WARNING);
96
-		return $default;
97
-	}
95
+        trigger_error("Could not convert ".var_export($value,1)." to boolean!", E_USER_WARNING);
96
+        return $default;
97
+    }
98 98
 
99
-	/**
100
-	 * @param string $value
101
-	 * @param integer $default
102
-	 * @return integer
103
-	 * @static
104
-	 */
105
-	public static function toInt($value, $default) {
106
-		$value = trim($value);
107
-		if(is_numeric($value)) {
108
-			return (int)$value;
109
-		} else {
110
-			return $default;
111
-		}
112
-	}
99
+    /**
100
+     * @param string $value
101
+     * @param integer $default
102
+     * @return integer
103
+     * @static
104
+     */
105
+    public static function toInt($value, $default) {
106
+        $value = trim($value);
107
+        if(is_numeric($value)) {
108
+            return (int)$value;
109
+        } else {
110
+            return $default;
111
+        }
112
+    }
113 113
 
114
-	/**
115
-	 * Converts a standard or custom priority level to a Level
116
-	 * object.
117
-	 *
118
-	 * <p> If <var>$value</var> is of form "<b>level#full_file_classname</b>",
119
-	 * where <i>full_file_classname</i> means the class filename with path
120
-	 * but without php extension, then the specified class' <i>toLevel()</i> method
121
-	 * is called to process the specified level string; if no '#'
122
-	 * character is present, then the default {@link LoggerLevel}
123
-	 * class is used to process the level value.</p>
124
-	 *
125
-	 * <p>As a special case, if the <var>$value</var> parameter is
126
-	 * equal to the string "NULL", then the value <i>null</i> will
127
-	 * be returned.</p>
128
-	 *
129
-	 * <p>If any error occurs while converting the value to a level,
130
-	 * the <var>$defaultValue</var> parameter, which may be
131
-	 * <i>null</i>, is returned.</p>
132
-	 *
133
-	 * <p>Case of <var>$value</var> is insignificant for the level level, but is
134
-	 * significant for the class name part, if present.</p>
135
-	 *
136
-	 * @param string $value
137
-	 * @param LoggerLevel $defaultValue
138
-	 * @return LoggerLevel a {@link LoggerLevel} or null
139
-	 * @static
140
-	 */
141
-	public static function toLevel($value, $defaultValue) {
142
-		if($value === null) {
143
-			return $defaultValue;
144
-		}
145
-		$hashIndex = strpos($value, '#');
146
-		if($hashIndex === false) {
147
-			if("NULL" == strtoupper($value)) {
148
-				return null;
149
-			} else {
150
-				// no class name specified : use standard Level class
151
-				return LoggerLevel::toLevel($value, $defaultValue);
152
-			}
153
-		}
114
+    /**
115
+     * Converts a standard or custom priority level to a Level
116
+     * object.
117
+     *
118
+     * <p> If <var>$value</var> is of form "<b>level#full_file_classname</b>",
119
+     * where <i>full_file_classname</i> means the class filename with path
120
+     * but without php extension, then the specified class' <i>toLevel()</i> method
121
+     * is called to process the specified level string; if no '#'
122
+     * character is present, then the default {@link LoggerLevel}
123
+     * class is used to process the level value.</p>
124
+     *
125
+     * <p>As a special case, if the <var>$value</var> parameter is
126
+     * equal to the string "NULL", then the value <i>null</i> will
127
+     * be returned.</p>
128
+     *
129
+     * <p>If any error occurs while converting the value to a level,
130
+     * the <var>$defaultValue</var> parameter, which may be
131
+     * <i>null</i>, is returned.</p>
132
+     *
133
+     * <p>Case of <var>$value</var> is insignificant for the level level, but is
134
+     * significant for the class name part, if present.</p>
135
+     *
136
+     * @param string $value
137
+     * @param LoggerLevel $defaultValue
138
+     * @return LoggerLevel a {@link LoggerLevel} or null
139
+     * @static
140
+     */
141
+    public static function toLevel($value, $defaultValue) {
142
+        if($value === null) {
143
+            return $defaultValue;
144
+        }
145
+        $hashIndex = strpos($value, '#');
146
+        if($hashIndex === false) {
147
+            if("NULL" == strtoupper($value)) {
148
+                return null;
149
+            } else {
150
+                // no class name specified : use standard Level class
151
+                return LoggerLevel::toLevel($value, $defaultValue);
152
+            }
153
+        }
154 154
 
155
-		$result = $defaultValue;
155
+        $result = $defaultValue;
156 156
 
157
-		$clazz = substr($value, ($hashIndex + 1));
158
-		$levelName = substr($value, 0, $hashIndex);
157
+        $clazz = substr($value, ($hashIndex + 1));
158
+        $levelName = substr($value, 0, $hashIndex);
159 159
 
160
-		// This is degenerate case but you never know.
161
-		if("NULL" == strtoupper($levelName)) {
162
-			return null;
163
-		}
160
+        // This is degenerate case but you never know.
161
+        if("NULL" == strtoupper($levelName)) {
162
+            return null;
163
+        }
164 164
 
165
-		$clazz = basename($clazz);
165
+        $clazz = basename($clazz);
166 166
 
167
-		if(class_exists($clazz)) {
168
-			$result = @call_user_func(array($clazz, 'toLevel'), $levelName, $defaultValue);
169
-			if(!$result instanceof LoggerLevel) {
170
-				$result = $defaultValue;
171
-			}
172
-		} 
173
-		return $result;
174
-	}
167
+        if(class_exists($clazz)) {
168
+            $result = @call_user_func(array($clazz, 'toLevel'), $levelName, $defaultValue);
169
+            if(!$result instanceof LoggerLevel) {
170
+                $result = $defaultValue;
171
+            }
172
+        } 
173
+        return $result;
174
+    }
175 175
 
176
-	/**
177
-	 * @param string $value
178
-	 * @param float $default
179
-	 * @return float
180
-	 *
181
-	 * @static
182
-	 */
183
-	public static function toFileSize($value, $default) {
184
-		if($value === null) {
185
-			return $default;
186
-		}
176
+    /**
177
+     * @param string $value
178
+     * @param float $default
179
+     * @return float
180
+     *
181
+     * @static
182
+     */
183
+    public static function toFileSize($value, $default) {
184
+        if($value === null) {
185
+            return $default;
186
+        }
187 187
 
188
-		$s = strtoupper(trim($value));
189
-		$multiplier = (float)1;
190
-		if(($index = strpos($s, 'KB')) !== false) {
191
-			$multiplier = 1024;
192
-			$s = substr($s, 0, $index);
193
-		} else if(($index = strpos($s, 'MB')) !== false) {
194
-			$multiplier = 1024 * 1024;
195
-			$s = substr($s, 0, $index);
196
-		} else if(($index = strpos($s, 'GB')) !== false) {
197
-			$multiplier = 1024 * 1024 * 1024;
198
-			$s = substr($s, 0, $index);
199
-		}
200
-		if(is_numeric($s)) {
201
-			return (float)$s * $multiplier;
202
-		} 
203
-		return $default;
204
-	}
188
+        $s = strtoupper(trim($value));
189
+        $multiplier = (float)1;
190
+        if(($index = strpos($s, 'KB')) !== false) {
191
+            $multiplier = 1024;
192
+            $s = substr($s, 0, $index);
193
+        } else if(($index = strpos($s, 'MB')) !== false) {
194
+            $multiplier = 1024 * 1024;
195
+            $s = substr($s, 0, $index);
196
+        } else if(($index = strpos($s, 'GB')) !== false) {
197
+            $multiplier = 1024 * 1024 * 1024;
198
+            $s = substr($s, 0, $index);
199
+        }
200
+        if(is_numeric($s)) {
201
+            return (float)$s * $multiplier;
202
+        } 
203
+        return $default;
204
+    }
205 205
 
206
-	/**
207
-	 * Find the value corresponding to <var>$key</var> in
208
-	 * <var>$props</var>. Then perform variable substitution on the
209
-	 * found value.
210
-	 *
211
-	 * @param string $key
212
-	 * @param array $props
213
-	 * @return string
214
-	 *
215
-	 * @static
216
-	 */
217
-	public static function findAndSubst($key, $props) {
218
-		$value = @$props[$key];
206
+    /**
207
+     * Find the value corresponding to <var>$key</var> in
208
+     * <var>$props</var>. Then perform variable substitution on the
209
+     * found value.
210
+     *
211
+     * @param string $key
212
+     * @param array $props
213
+     * @return string
214
+     *
215
+     * @static
216
+     */
217
+    public static function findAndSubst($key, $props) {
218
+        $value = @$props[$key];
219 219
 
220 220
         // If coming from the LoggerConfiguratorIni, some options were
221 221
         // already mangled by parse_ini_file:
@@ -233,90 +233,90 @@  discard block
 block discarded – undo
233 233
         // explicitly set by the user and is different from an option which
234 234
         // has not been specified and therefore keeps its default value.
235 235
         //
236
-		// if(!empty($value)) {
237
-			return LoggerOptionConverter::substVars($value, $props);
238
-		// }
236
+        // if(!empty($value)) {
237
+            return LoggerOptionConverter::substVars($value, $props);
238
+        // }
239 239
     }
240 240
 
241
-	/**
242
-	 * Perform variable substitution in string <var>$val</var> from the
243
-	 * values of keys found with the {@link getSystemProperty()} method.
244
-	 * 
245
-	 * <p>The variable substitution delimeters are <b>${</b> and <b>}</b>.
246
-	 * 
247
-	 * <p>For example, if the "MY_CONSTANT" contains "value", then
248
-	 * the call
249
-	 * <code>
250
-	 * $s = LoggerOptionConverter::substituteVars("Value of key is ${MY_CONSTANT}.");
251
-	 * </code>
252
-	 * will set the variable <i>$s</i> to "Value of key is value.".</p>
253
-	 * 
254
-	 * <p>If no value could be found for the specified key, then the
255
-	 * <var>$props</var> parameter is searched, if the value could not
256
-	 * be found there, then substitution defaults to the empty string.</p>
257
-	 * 
258
-	 * <p>For example, if {@link getSystemProperty()} cannot find any value for the key
259
-	 * "inexistentKey", then the call
260
-	 * <code>
261
-	 * $s = LoggerOptionConverter::substVars("Value of inexistentKey is [${inexistentKey}]");
262
-	 * </code>
263
-	 * will set <var>$s</var> to "Value of inexistentKey is []".</p>
264
-	 * 
265
-	 * <p>A warn is thrown if <var>$val</var> contains a start delimeter "${" 
266
-	 * which is not balanced by a stop delimeter "}" and an empty string is returned.</p>
267
-	 * 
268
-	 * @author Avy Sharell
269
-	 * 
270
-	 * @param string $val The string on which variable substitution is performed.
271
-	 * @param array $props
272
-	 * @return string
273
-	 *
274
-	 * @static
275
-	 */
276
-	 // TODO: this method doesn't work correctly with key = true, it needs key = "true" which is odd
277
-	public static function substVars($val, $props = null) {
278
-		$sbuf = '';
279
-		$i = 0;
280
-		while(true) {
281
-			$j = strpos($val, self::DELIM_START, $i);
282
-			if($j === false) {
283
-				// no more variables
284
-				if($i == 0) { // this is a simple string
285
-					return $val;
286
-				} else { // add the tail string which contails no variables and return the result.
287
-					$sbuf .= substr($val, $i);
288
-					return $sbuf;
289
-				}
290
-			} else {
241
+    /**
242
+     * Perform variable substitution in string <var>$val</var> from the
243
+     * values of keys found with the {@link getSystemProperty()} method.
244
+     * 
245
+     * <p>The variable substitution delimeters are <b>${</b> and <b>}</b>.
246
+     * 
247
+     * <p>For example, if the "MY_CONSTANT" contains "value", then
248
+     * the call
249
+     * <code>
250
+     * $s = LoggerOptionConverter::substituteVars("Value of key is ${MY_CONSTANT}.");
251
+     * </code>
252
+     * will set the variable <i>$s</i> to "Value of key is value.".</p>
253
+     * 
254
+     * <p>If no value could be found for the specified key, then the
255
+     * <var>$props</var> parameter is searched, if the value could not
256
+     * be found there, then substitution defaults to the empty string.</p>
257
+     * 
258
+     * <p>For example, if {@link getSystemProperty()} cannot find any value for the key
259
+     * "inexistentKey", then the call
260
+     * <code>
261
+     * $s = LoggerOptionConverter::substVars("Value of inexistentKey is [${inexistentKey}]");
262
+     * </code>
263
+     * will set <var>$s</var> to "Value of inexistentKey is []".</p>
264
+     * 
265
+     * <p>A warn is thrown if <var>$val</var> contains a start delimeter "${" 
266
+     * which is not balanced by a stop delimeter "}" and an empty string is returned.</p>
267
+     * 
268
+     * @author Avy Sharell
269
+     * 
270
+     * @param string $val The string on which variable substitution is performed.
271
+     * @param array $props
272
+     * @return string
273
+     *
274
+     * @static
275
+     */
276
+        // TODO: this method doesn't work correctly with key = true, it needs key = "true" which is odd
277
+    public static function substVars($val, $props = null) {
278
+        $sbuf = '';
279
+        $i = 0;
280
+        while(true) {
281
+            $j = strpos($val, self::DELIM_START, $i);
282
+            if($j === false) {
283
+                // no more variables
284
+                if($i == 0) { // this is a simple string
285
+                    return $val;
286
+                } else { // add the tail string which contails no variables and return the result.
287
+                    $sbuf .= substr($val, $i);
288
+                    return $sbuf;
289
+                }
290
+            } else {
291 291
 			
292
-				$sbuf .= substr($val, $i, $j-$i);
293
-				$k = strpos($val, self::DELIM_STOP, $j);
294
-				if($k === false) {
295
-					// LoggerOptionConverter::substVars() has no closing brace. Opening brace
296
-					return '';
297
-				} else {
298
-					$j += self::START_LEN;
299
-					$key = substr($val, $j, $k - $j);
300
-					// first try in System properties
301
-					$replacement = LoggerOptionConverter::getSystemProperty($key, null);
302
-					// then try props parameter
303
-					if($replacement == null and $props !== null) {
304
-						$replacement = @$props[$key];
305
-					}
292
+                $sbuf .= substr($val, $i, $j-$i);
293
+                $k = strpos($val, self::DELIM_STOP, $j);
294
+                if($k === false) {
295
+                    // LoggerOptionConverter::substVars() has no closing brace. Opening brace
296
+                    return '';
297
+                } else {
298
+                    $j += self::START_LEN;
299
+                    $key = substr($val, $j, $k - $j);
300
+                    // first try in System properties
301
+                    $replacement = LoggerOptionConverter::getSystemProperty($key, null);
302
+                    // then try props parameter
303
+                    if($replacement == null and $props !== null) {
304
+                        $replacement = @$props[$key];
305
+                    }
306 306
 
307
-					if(!empty($replacement)) {
308
-						// Do variable substitution on the replacement string
309
-						// such that we can solve "Hello ${x2}" as "Hello p1" 
310
-						// the where the properties are
311
-						// x1=p1
312
-						// x2=${x1}
313
-						$recursiveReplacement = LoggerOptionConverter::substVars($replacement, $props);
314
-						$sbuf .= $recursiveReplacement;
315
-					}
316
-					$i = $k + self::DELIM_STOP_LEN;
317
-				}
318
-			}
319
-		}
320
-	}
307
+                    if(!empty($replacement)) {
308
+                        // Do variable substitution on the replacement string
309
+                        // such that we can solve "Hello ${x2}" as "Hello p1" 
310
+                        // the where the properties are
311
+                        // x1=p1
312
+                        // x2=${x1}
313
+                        $recursiveReplacement = LoggerOptionConverter::substVars($replacement, $props);
314
+                        $sbuf .= $recursiveReplacement;
315
+                    }
316
+                    $i = $k + self::DELIM_STOP_LEN;
317
+                }
318
+            }
319
+        }
320
+    }
321 321
 
322 322
 }
Please login to merge, or discard this patch.
main/inc/lib/phpdocx/lib/log4php/helpers/LoggerLiteralPatternConverter.php 1 patch
Indentation   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -24,34 +24,34 @@
 block discarded – undo
24 24
  */
25 25
 class LoggerLiteralPatternConverter extends LoggerPatternConverter {
26 26
 	
27
-	/**
28
-	 * @var string
29
-	 */
30
-	private $literal;
27
+    /**
28
+     * @var string
29
+     */
30
+    private $literal;
31 31
 
32
-	/**
33
-	 * Constructor
34
-	 *
35
-	 * @param string $value
36
-	 */
37
-	public function __construct($value) {
38
-		$this->literal = $value;
39
-	}
32
+    /**
33
+     * Constructor
34
+     *
35
+     * @param string $value
36
+     */
37
+    public function __construct($value) {
38
+        $this->literal = $value;
39
+    }
40 40
 
41
-	/**
42
-	 * @param string &$sbuf
43
-	 * @param LoggerLoggingEvent $event
44
-	 */
45
-	public function format(&$sbuf, $event) {
46
-		$sbuf .= $this->literal;
47
-	}
41
+    /**
42
+     * @param string &$sbuf
43
+     * @param LoggerLoggingEvent $event
44
+     */
45
+    public function format(&$sbuf, $event) {
46
+        $sbuf .= $this->literal;
47
+    }
48 48
 
49
-	/**
50
-	 * @param LoggerLoggingEvent $event
51
-	 * @return string
52
-	 */
53
-	public function convert($event) {
54
-		return $this->literal;
55
-	}
49
+    /**
50
+     * @param LoggerLoggingEvent $event
51
+     * @return string
52
+     */
53
+    public function convert($event) {
54
+        return $this->literal;
55
+    }
56 56
 }
57 57
 
Please login to merge, or discard this patch.
main/inc/lib/phpdocx/lib/log4php/filters/LoggerFilterLevelRange.php 1 patch
Indentation   +87 added lines, -87 removed lines patch added patch discarded remove patch
@@ -1,22 +1,22 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * Licensed to the Apache Software Foundation (ASF) under one or more
4
- * contributor license agreements. See the NOTICE file distributed with
5
- * this work for additional information regarding copyright ownership.
6
- * The ASF licenses this file to You under the Apache License, Version 2.0
7
- * (the "License"); you may not use this file except in compliance with
8
- * the License. You may obtain a copy of the License at
9
- *
10
- *	   http://www.apache.org/licenses/LICENSE-2.0
11
- *
12
- * Unless required by applicable law or agreed to in writing, software
13
- * distributed under the License is distributed on an "AS IS" BASIS,
14
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
- * See the License for the specific language governing permissions and
16
- * limitations under the License.
17
- *
18
- * @package log4php
19
- */
3
+     * Licensed to the Apache Software Foundation (ASF) under one or more
4
+     * contributor license agreements. See the NOTICE file distributed with
5
+     * this work for additional information regarding copyright ownership.
6
+     * The ASF licenses this file to You under the Apache License, Version 2.0
7
+     * (the "License"); you may not use this file except in compliance with
8
+     * the License. You may obtain a copy of the License at
9
+     *
10
+     *	   http://www.apache.org/licenses/LICENSE-2.0
11
+     *
12
+     * Unless required by applicable law or agreed to in writing, software
13
+     * distributed under the License is distributed on an "AS IS" BASIS,
14
+     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+     * See the License for the specific language governing permissions and
16
+     * limitations under the License.
17
+     *
18
+     * @package log4php
19
+     */
20 20
 
21 21
 /**
22 22
  * This is a very simple filter based on level matching, which can be
@@ -64,83 +64,83 @@  discard block
 block discarded – undo
64 64
  */
65 65
 class LoggerFilterLevelRange extends LoggerFilter {
66 66
 
67
-	/**
68
-	 * @var boolean
69
-	 */
70
-	private $acceptOnMatch = true;
67
+    /**
68
+     * @var boolean
69
+     */
70
+    private $acceptOnMatch = true;
71 71
 
72
-	/**
73
-	 * @var LoggerLevel
74
-	 */
75
-	private $levelMin;
72
+    /**
73
+     * @var LoggerLevel
74
+     */
75
+    private $levelMin;
76 76
   
77
-	/**
78
-	 * @var LoggerLevel
79
-	 */
80
-	private $levelMax;
77
+    /**
78
+     * @var LoggerLevel
79
+     */
80
+    private $levelMax;
81 81
 
82
-	/**
83
-	 * @param boolean $acceptOnMatch
84
-	 */
85
-	public function setAcceptOnMatch($acceptOnMatch) {
86
-		$this->acceptOnMatch = LoggerOptionConverter::toBoolean($acceptOnMatch, true); 
87
-	}
82
+    /**
83
+     * @param boolean $acceptOnMatch
84
+     */
85
+    public function setAcceptOnMatch($acceptOnMatch) {
86
+        $this->acceptOnMatch = LoggerOptionConverter::toBoolean($acceptOnMatch, true); 
87
+    }
88 88
 	
89
-	/**
90
-	 * @param string $l the level min to match
91
-	 */
92
-	public function setLevelMin($l) {
93
-		if($l instanceof LoggerLevel) {
94
-		    $this->levelMin = $l;
95
-		} else {
96
-			$this->levelMin = LoggerOptionConverter::toLevel($l, null);
97
-		}
98
-	}
89
+    /**
90
+     * @param string $l the level min to match
91
+     */
92
+    public function setLevelMin($l) {
93
+        if($l instanceof LoggerLevel) {
94
+            $this->levelMin = $l;
95
+        } else {
96
+            $this->levelMin = LoggerOptionConverter::toLevel($l, null);
97
+        }
98
+    }
99 99
 
100
-	/**
101
-	 * @param string $l the level max to match
102
-	 */
103
-	public function setLevelMax($l) {
104
-		if($l instanceof LoggerLevel) {
105
-		    $this->levelMax = $l;
106
-		} else {
107
-			$this->levelMax = LoggerOptionConverter::toLevel($l, null);
108
-		}
109
-	}
100
+    /**
101
+     * @param string $l the level max to match
102
+     */
103
+    public function setLevelMax($l) {
104
+        if($l instanceof LoggerLevel) {
105
+            $this->levelMax = $l;
106
+        } else {
107
+            $this->levelMax = LoggerOptionConverter::toLevel($l, null);
108
+        }
109
+    }
110 110
 
111
-	/**
112
-	 * Return the decision of this filter.
113
-	 *
114
-	 * @param LoggerLoggingEvent $event
115
-	 * @return integer
116
-	 */
117
-	public function decide(LoggerLoggingEvent $event) {
118
-		$level = $event->getLevel();
111
+    /**
112
+     * Return the decision of this filter.
113
+     *
114
+     * @param LoggerLoggingEvent $event
115
+     * @return integer
116
+     */
117
+    public function decide(LoggerLoggingEvent $event) {
118
+        $level = $event->getLevel();
119 119
 		
120
-		if($this->levelMin !== null) {
121
-			if($level->isGreaterOrEqual($this->levelMin) == false) {
122
-				// level of event is less than minimum
123
-				return LoggerFilter::DENY;
124
-			}
125
-		}
120
+        if($this->levelMin !== null) {
121
+            if($level->isGreaterOrEqual($this->levelMin) == false) {
122
+                // level of event is less than minimum
123
+                return LoggerFilter::DENY;
124
+            }
125
+        }
126 126
 
127
-		if($this->levelMax !== null) {
128
-			if($level->toInt() > $this->levelMax->toInt()) {
129
-				// level of event is greater than maximum
130
-				// Alas, there is no Level.isGreater method. and using
131
-				// a combo of isGreaterOrEqual && !Equal seems worse than
132
-				// checking the int values of the level objects..
133
-				return LoggerFilter::DENY;
134
-			}
135
-		}
127
+        if($this->levelMax !== null) {
128
+            if($level->toInt() > $this->levelMax->toInt()) {
129
+                // level of event is greater than maximum
130
+                // Alas, there is no Level.isGreater method. and using
131
+                // a combo of isGreaterOrEqual && !Equal seems worse than
132
+                // checking the int values of the level objects..
133
+                return LoggerFilter::DENY;
134
+            }
135
+        }
136 136
 
137
-		if($this->acceptOnMatch) {
138
-			// this filter set up to bypass later filters and always return
139
-			// accept if level in range
140
-			return LoggerFilter::ACCEPT;
141
-		} else {
142
-			// event is ok for this filter; allow later filters to have a look..
143
-			return LoggerFilter::NEUTRAL;
144
-		}
145
-	}
137
+        if($this->acceptOnMatch) {
138
+            // this filter set up to bypass later filters and always return
139
+            // accept if level in range
140
+            return LoggerFilter::ACCEPT;
141
+        } else {
142
+            // event is ok for this filter; allow later filters to have a look..
143
+            return LoggerFilter::NEUTRAL;
144
+        }
145
+    }
146 146
 }
Please login to merge, or discard this patch.
main/inc/lib/phpdocx/lib/log4php/filters/LoggerFilterStringMatch.php 1 patch
Indentation   +50 added lines, -50 removed lines patch added patch discarded remove patch
@@ -1,22 +1,22 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * Licensed to the Apache Software Foundation (ASF) under one or more
4
- * contributor license agreements. See the NOTICE file distributed with
5
- * this work for additional information regarding copyright ownership.
6
- * The ASF licenses this file to You under the Apache License, Version 2.0
7
- * (the "License"); you may not use this file except in compliance with
8
- * the License. You may obtain a copy of the License at
9
- *
10
- *	   http://www.apache.org/licenses/LICENSE-2.0
11
- *
12
- * Unless required by applicable law or agreed to in writing, software
13
- * distributed under the License is distributed on an "AS IS" BASIS,
14
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
- * See the License for the specific language governing permissions and
16
- * limitations under the License.
17
- *
18
- * @package log4php
19
- */
3
+     * Licensed to the Apache Software Foundation (ASF) under one or more
4
+     * contributor license agreements. See the NOTICE file distributed with
5
+     * this work for additional information regarding copyright ownership.
6
+     * The ASF licenses this file to You under the Apache License, Version 2.0
7
+     * (the "License"); you may not use this file except in compliance with
8
+     * the License. You may obtain a copy of the License at
9
+     *
10
+     *	   http://www.apache.org/licenses/LICENSE-2.0
11
+     *
12
+     * Unless required by applicable law or agreed to in writing, software
13
+     * distributed under the License is distributed on an "AS IS" BASIS,
14
+     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+     * See the License for the specific language governing permissions and
16
+     * limitations under the License.
17
+     *
18
+     * @package log4php
19
+     */
20 20
 
21 21
 /**
22 22
  * This is a very simple filter based on string matching.
@@ -47,43 +47,43 @@  discard block
 block discarded – undo
47 47
  */
48 48
 class LoggerFilterStringMatch extends LoggerFilter {
49 49
 
50
-	/**
51
-	 * @var boolean
52
-	 */
53
-	private $acceptOnMatch = true;
50
+    /**
51
+     * @var boolean
52
+     */
53
+    private $acceptOnMatch = true;
54 54
 
55
-	/**
56
-	 * @var string
57
-	 */
58
-	private $stringToMatch = null;
55
+    /**
56
+     * @var string
57
+     */
58
+    private $stringToMatch = null;
59 59
 
60
-	/**
61
-	 * @param mixed $acceptOnMatch a boolean or a string ('true' or 'false')
62
-	 */
63
-	public function setAcceptOnMatch($acceptOnMatch) {
64
-		$this->acceptOnMatch = is_bool($acceptOnMatch) ? $acceptOnMatch : (bool)(strtolower($acceptOnMatch) == 'true');
65
-	}
60
+    /**
61
+     * @param mixed $acceptOnMatch a boolean or a string ('true' or 'false')
62
+     */
63
+    public function setAcceptOnMatch($acceptOnMatch) {
64
+        $this->acceptOnMatch = is_bool($acceptOnMatch) ? $acceptOnMatch : (bool)(strtolower($acceptOnMatch) == 'true');
65
+    }
66 66
 	
67
-	/**
68
-	 * @param string $s the string to match
69
-	 */
70
-	public function setStringToMatch($s) {
71
-		$this->stringToMatch = $s;
72
-	}
67
+    /**
68
+     * @param string $s the string to match
69
+     */
70
+    public function setStringToMatch($s) {
71
+        $this->stringToMatch = $s;
72
+    }
73 73
 
74
-	/**
75
-	 * @return integer a {@link LOGGER_FILTER_NEUTRAL} is there is no string match.
76
-	 */
77
-	public function decide(LoggerLoggingEvent $event) {
78
-		$msg = $event->getRenderedMessage();
74
+    /**
75
+     * @return integer a {@link LOGGER_FILTER_NEUTRAL} is there is no string match.
76
+     */
77
+    public function decide(LoggerLoggingEvent $event) {
78
+        $msg = $event->getRenderedMessage();
79 79
 		
80
-		if($msg === null or $this->stringToMatch === null) {
81
-			return LoggerFilter::NEUTRAL;
82
-		}
80
+        if($msg === null or $this->stringToMatch === null) {
81
+            return LoggerFilter::NEUTRAL;
82
+        }
83 83
 		
84
-		if(strpos($msg, $this->stringToMatch) !== false ) {
85
-			return ($this->acceptOnMatch) ? LoggerFilter::ACCEPT : LoggerFilter::DENY;
86
-		}
87
-		return LoggerFilter::NEUTRAL;
88
-	}
84
+        if(strpos($msg, $this->stringToMatch) !== false ) {
85
+            return ($this->acceptOnMatch) ? LoggerFilter::ACCEPT : LoggerFilter::DENY;
86
+        }
87
+        return LoggerFilter::NEUTRAL;
88
+    }
89 89
 }
Please login to merge, or discard this patch.
main/inc/lib/phpdocx/lib/log4php/LoggerHierarchy.php 1 patch
Indentation   +185 added lines, -185 removed lines patch added patch discarded remove patch
@@ -1,22 +1,22 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * Licensed to the Apache Software Foundation (ASF) under one or more
4
- * contributor license agreements. See the NOTICE file distributed with
5
- * this work for additional information regarding copyright ownership.
6
- * The ASF licenses this file to You under the Apache License, Version 2.0
7
- * (the "License"); you may not use this file except in compliance with
8
- * the License. You may obtain a copy of the License at
9
- *
10
- *	   http://www.apache.org/licenses/LICENSE-2.0
11
- *
12
- * Unless required by applicable law or agreed to in writing, software
13
- * distributed under the License is distributed on an "AS IS" BASIS,
14
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
- * See the License for the specific language governing permissions and
16
- * limitations under the License.
17
- *
18
- * @package log4php
19
- */
3
+     * Licensed to the Apache Software Foundation (ASF) under one or more
4
+     * contributor license agreements. See the NOTICE file distributed with
5
+     * this work for additional information regarding copyright ownership.
6
+     * The ASF licenses this file to You under the Apache License, Version 2.0
7
+     * (the "License"); you may not use this file except in compliance with
8
+     * the License. You may obtain a copy of the License at
9
+     *
10
+     *	   http://www.apache.org/licenses/LICENSE-2.0
11
+     *
12
+     * Unless required by applicable law or agreed to in writing, software
13
+     * distributed under the License is distributed on an "AS IS" BASIS,
14
+     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+     * See the License for the specific language governing permissions and
16
+     * limitations under the License.
17
+     *
18
+     * @package log4php
19
+     */
20 20
 
21 21
 /**
22 22
  * This class is specialized in retrieving loggers by name and also maintaining 
@@ -47,199 +47,199 @@  discard block
 block discarded – undo
47 47
  * @version $Revision: 822448 $
48 48
  * @package log4php
49 49
  */
50
- /*
50
+    /*
51 51
   * TODO:
52 52
   * - addHierarchyEventListener($listener) not supported
53 53
   * - emitNoAppenderWarning($cat) not supported
54 54
   * - fireAddAppenderEvent not supported
55 55
   */
56 56
 class LoggerHierarchy {
57
-	/** Default Factory  */
58
-	protected $defaultFactory;
57
+    /** Default Factory  */
58
+    protected $defaultFactory;
59 59
 	
60
-	/** array hierarchy tree. saves here all loggers */
61
-	protected $ht = array();
60
+    /** array hierarchy tree. saves here all loggers */
61
+    protected $ht = array();
62 62
 	
63
-	/** The root Logger */
64
-	protected $root = null;
63
+    /** The root Logger */
64
+    protected $root = null;
65 65
 	
66
-	/** LoggerRendererMap */
67
-	protected $rendererMap;
66
+    /** LoggerRendererMap */
67
+    protected $rendererMap;
68 68
 
69
-	/** LoggerLevel main level threshold */
70
-	protected $threshold;
69
+    /** LoggerLevel main level threshold */
70
+    protected $threshold;
71 71
 	
72
-	/**
73
-	 * Create a new logger hierarchy.
74
-	 * @param object $root the root logger
75
-	 */
76
-	public function __construct(LoggerRoot $root) {
77
-		$this->root = $root;
78
-		$this->setThreshold(LoggerLevel::getLevelAll());
79
-		$this->rendererMap = new LoggerRendererMap();
80
-	}
72
+    /**
73
+     * Create a new logger hierarchy.
74
+     * @param object $root the root logger
75
+     */
76
+    public function __construct(LoggerRoot $root) {
77
+        $this->root = $root;
78
+        $this->setThreshold(LoggerLevel::getLevelAll());
79
+        $this->rendererMap = new LoggerRendererMap();
80
+    }
81 81
 	 
82
-	/**
83
-	 * This call will clear all logger definitions from the internal hashtable.
84
-	 */
85
-	public function clear() {
86
-		$this->ht = array();
87
-	}
82
+    /**
83
+     * This call will clear all logger definitions from the internal hashtable.
84
+     */
85
+    public function clear() {
86
+        $this->ht = array();
87
+    }
88 88
 	  
89
-	/**
90
-	 * Check if the named logger exists in the hierarchy.
91
-	 * @param string $name
92
-	 * @return boolean
93
-	 */
94
-	public function exists($name) {
95
-		return isset($this->ht[$name]);
96
-	}
89
+    /**
90
+     * Check if the named logger exists in the hierarchy.
91
+     * @param string $name
92
+     * @return boolean
93
+     */
94
+    public function exists($name) {
95
+        return isset($this->ht[$name]);
96
+    }
97 97
 
98
-	/**
99
-	 * Returns all the currently defined categories in this hierarchy as an array.
100
-	 * @return array
101
-	 */	 
102
-	public function getCurrentLoggers() {
103
-		return array_values($this->ht);
104
-	}
98
+    /**
99
+     * Returns all the currently defined categories in this hierarchy as an array.
100
+     * @return array
101
+     */	 
102
+    public function getCurrentLoggers() {
103
+        return array_values($this->ht);
104
+    }
105 105
 	
106
-	/**
107
-	 * Return a new logger instance named as the first parameter using the default factory.
108
-	 * 
109
-	 * @param string $name logger name
110
-	 * @param LoggerFactory $factory a {@link LoggerFactory} instance or null	  
111
-	 * @return Logger
112
-	 */
113
-	public function getLogger($name) {
114
-		if(!isset($this->ht[$name])) {
115
-			$this->ht[$name] = new Logger($name);;
116
-			// TODO: isn't necessary, access via singleton?
117
-			// $this->ht[$name]->setHierarchy($this);
118
-			$nodes = explode('.', $name);
119
-			$firstNode = array_shift($nodes);
106
+    /**
107
+     * Return a new logger instance named as the first parameter using the default factory.
108
+     * 
109
+     * @param string $name logger name
110
+     * @param LoggerFactory $factory a {@link LoggerFactory} instance or null	  
111
+     * @return Logger
112
+     */
113
+    public function getLogger($name) {
114
+        if(!isset($this->ht[$name])) {
115
+            $this->ht[$name] = new Logger($name);;
116
+            // TODO: isn't necessary, access via singleton?
117
+            // $this->ht[$name]->setHierarchy($this);
118
+            $nodes = explode('.', $name);
119
+            $firstNode = array_shift($nodes);
120 120
 			
121
-			// if name is not a first node but another first node is their
122
-			if($firstNode != $name and isset($this->ht[$firstNode])) {
123
-				$this->ht[$name]->setParent($this->ht[$firstNode]);
124
-			} else {
125
-				// if there is no father, set root logger as father
126
-				$this->ht[$name]->setParent($this->root);
127
-			} 
121
+            // if name is not a first node but another first node is their
122
+            if($firstNode != $name and isset($this->ht[$firstNode])) {
123
+                $this->ht[$name]->setParent($this->ht[$firstNode]);
124
+            } else {
125
+                // if there is no father, set root logger as father
126
+                $this->ht[$name]->setParent($this->root);
127
+            } 
128 128
 		
129
-			// if there are more nodes than one
130
-			if(count($nodes) > 0) {
131
-				// find parent node
132
-				foreach($nodes as $node) {
133
-					$parentNode = "$firstNode.$node";
134
-					if(isset($this->ht[$parentNode]) and $parentNode != $name) {
129
+            // if there are more nodes than one
130
+            if(count($nodes) > 0) {
131
+                // find parent node
132
+                foreach($nodes as $node) {
133
+                    $parentNode = "$firstNode.$node";
134
+                    if(isset($this->ht[$parentNode]) and $parentNode != $name) {
135 135
 		
136
-						$this->ht[$name]->setParent($this->ht[$parentNode]);
137
-					}
138
-					$firstNode .= ".$node";
139
-				}
140
-			}
141
-		}		
136
+                        $this->ht[$name]->setParent($this->ht[$parentNode]);
137
+                    }
138
+                    $firstNode .= ".$node";
139
+                }
140
+            }
141
+        }		
142 142
 		
143
-		return $this->ht[$name];
144
-	} 
143
+        return $this->ht[$name];
144
+    } 
145 145
 	
146
-	/**
147
-	 * @return LoggerRendererMap Get the renderer map for this hierarchy.
148
-	 */
149
-	public function getRendererMap() {
150
-		return $this->rendererMap;
151
-	}
146
+    /**
147
+     * @return LoggerRendererMap Get the renderer map for this hierarchy.
148
+     */
149
+    public function getRendererMap() {
150
+        return $this->rendererMap;
151
+    }
152 152
 	
153
-	/**
154
-	 * @return LoggerRoot Get the root of this hierarchy.
155
-	 */ 
156
-	public function getRootLogger() {
157
-		if(!isset($this->root) or $this->root == null) {
158
-			$this->root = new LoggerRoot();
159
-		}
160
-		return $this->root;
161
-	}
153
+    /**
154
+     * @return LoggerRoot Get the root of this hierarchy.
155
+     */ 
156
+    public function getRootLogger() {
157
+        if(!isset($this->root) or $this->root == null) {
158
+            $this->root = new LoggerRoot();
159
+        }
160
+        return $this->root;
161
+    }
162 162
 	 
163
-	/**
164
-	 * @return LoggerLevel Returns the threshold Level.
165
-	 */
166
-	public function getThreshold() {
167
-		return $this->threshold;
168
-	} 
163
+    /**
164
+     * @return LoggerLevel Returns the threshold Level.
165
+     */
166
+    public function getThreshold() {
167
+        return $this->threshold;
168
+    } 
169 169
 
170
-	/**
171
-	 * This method will return true if this repository is disabled 
172
-	 * for level object passed as parameter and false otherwise.
173
-	 * @return boolean
174
-	 */
175
-	public function isDisabled(LoggerLevel $level) {
176
-		return ($this->threshold->toInt() > $level->toInt());
177
-	}
170
+    /**
171
+     * This method will return true if this repository is disabled 
172
+     * for level object passed as parameter and false otherwise.
173
+     * @return boolean
174
+     */
175
+    public function isDisabled(LoggerLevel $level) {
176
+        return ($this->threshold->toInt() > $level->toInt());
177
+    }
178 178
 	
179
-	/**
180
-	 * Reset all values contained in this hierarchy instance to their
181
-	 * default. 
182
-	 *
183
-	 * This removes all appenders from all categories, sets
184
-	 * the level of all non-root categories to <i>null</i>,
185
-	 * sets their additivity flag to <i>true</i> and sets the level
186
-	 * of the root logger to {@link LOGGER_LEVEL_DEBUG}.  Moreover,
187
-	 * message disabling is set its default "off" value.
188
-	 * 
189
-	 * <p>Existing categories are not removed. They are just reset.
190
-	 *
191
-	 * <p>This method should be used sparingly and with care as it will
192
-	 * block all logging until it is completed.</p>
193
-	 */
194
-	public function resetConfiguration() {
195
-		$root = $this->getRootLogger();
179
+    /**
180
+     * Reset all values contained in this hierarchy instance to their
181
+     * default. 
182
+     *
183
+     * This removes all appenders from all categories, sets
184
+     * the level of all non-root categories to <i>null</i>,
185
+     * sets their additivity flag to <i>true</i> and sets the level
186
+     * of the root logger to {@link LOGGER_LEVEL_DEBUG}.  Moreover,
187
+     * message disabling is set its default "off" value.
188
+     * 
189
+     * <p>Existing categories are not removed. They are just reset.
190
+     *
191
+     * <p>This method should be used sparingly and with care as it will
192
+     * block all logging until it is completed.</p>
193
+     */
194
+    public function resetConfiguration() {
195
+        $root = $this->getRootLogger();
196 196
 		
197
-		$root->setLevel(LoggerLevel::getLevelDebug());
198
-		$this->setThreshold(LoggerLevel::getLevelAll());
199
-		$this->shutDown();
200
-		$loggers = $this->getCurrentLoggers();
201
-		$enumLoggers = count($loggers);
202
-		for($i = 0; $i < $enumLoggers; $i++) {
203
-			$loggers[$i]->setLevel(null);
204
-			$loggers[$i]->setAdditivity(true);
205
-			$loggers[$i]->removeAllAppenders();
206
-		}
207
-		$this->rendererMap->clear();
208
-	}
197
+        $root->setLevel(LoggerLevel::getLevelDebug());
198
+        $this->setThreshold(LoggerLevel::getLevelAll());
199
+        $this->shutDown();
200
+        $loggers = $this->getCurrentLoggers();
201
+        $enumLoggers = count($loggers);
202
+        for($i = 0; $i < $enumLoggers; $i++) {
203
+            $loggers[$i]->setLevel(null);
204
+            $loggers[$i]->setAdditivity(true);
205
+            $loggers[$i]->removeAllAppenders();
206
+        }
207
+        $this->rendererMap->clear();
208
+    }
209 209
 	
210
-	/**
211
-	 * set a new threshold level
212
-	 *
213
-	 * @param LoggerLevel $l
214
-	 */
215
-	public function setThreshold(LoggerLevel $l) {
216
-		if($l !== null) {
217
-			$this->threshold = $l;
218
-		}
219
-	}
210
+    /**
211
+     * set a new threshold level
212
+     *
213
+     * @param LoggerLevel $l
214
+     */
215
+    public function setThreshold(LoggerLevel $l) {
216
+        if($l !== null) {
217
+            $this->threshold = $l;
218
+        }
219
+    }
220 220
 	
221
-	/**
222
-	 * Shutting down a hierarchy will <i>safely</i> close and remove
223
-	 * all appenders in all categories including the root logger.
224
-	 * 
225
-	 * <p>Some appenders such as {@link LoggerSocketAppender}
226
-	 * need to be closed before the
227
-	 * application exists. Otherwise, pending logging events might be
228
-	 * lost.
229
-	 * 
230
-	 * <p>The shutdown method is careful to close nested
231
-	 * appenders before closing regular appenders. This is allows
232
-	 * configurations where a regular appender is attached to a logger
233
-	 * and again to a nested appender.
234
-	 */
235
-	public function shutdown() {
236
-		$this->root->removeAllAppenders();
237
-		$cats = $this->getCurrentLoggers();
238
-		$enumCats = count($cats);		  
239
-		if($enumCats > 0) {
240
-			for($i = 0; $i < $enumCats; $i++) {
241
-				$cats[$i]->removeAllAppenders();
242
-			}
243
-		}
244
-	}
221
+    /**
222
+     * Shutting down a hierarchy will <i>safely</i> close and remove
223
+     * all appenders in all categories including the root logger.
224
+     * 
225
+     * <p>Some appenders such as {@link LoggerSocketAppender}
226
+     * need to be closed before the
227
+     * application exists. Otherwise, pending logging events might be
228
+     * lost.
229
+     * 
230
+     * <p>The shutdown method is careful to close nested
231
+     * appenders before closing regular appenders. This is allows
232
+     * configurations where a regular appender is attached to a logger
233
+     * and again to a nested appender.
234
+     */
235
+    public function shutdown() {
236
+        $this->root->removeAllAppenders();
237
+        $cats = $this->getCurrentLoggers();
238
+        $enumCats = count($cats);		  
239
+        if($enumCats > 0) {
240
+            for($i = 0; $i < $enumCats; $i++) {
241
+                $cats[$i]->removeAllAppenders();
242
+            }
243
+        }
244
+    }
245 245
 } 
Please login to merge, or discard this patch.
main/inc/lib/phpdocx/lib/log4php/configurators/LoggerConfiguratorPhp.php 1 patch
Indentation   +89 added lines, -89 removed lines patch added patch discarded remove patch
@@ -1,22 +1,22 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * Licensed to the Apache Software Foundation (ASF) under one or more
4
- * contributor license agreements. See the NOTICE file distributed with
5
- * this work for additional information regarding copyright ownership.
6
- * The ASF licenses this file to You under the Apache License, Version 2.0
7
- * (the "License"); you may not use this file except in compliance with
8
- * the License. You may obtain a copy of the License at
9
- *
10
- *	   http://www.apache.org/licenses/LICENSE-2.0
11
- *
12
- * Unless required by applicable law or agreed to in writing, software
13
- * distributed under the License is distributed on an "AS IS" BASIS,
14
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
- * See the License for the specific language governing permissions and
16
- * limitations under the License.
17
- *
18
- * @package log4php
19
- */
3
+     * Licensed to the Apache Software Foundation (ASF) under one or more
4
+     * contributor license agreements. See the NOTICE file distributed with
5
+     * this work for additional information regarding copyright ownership.
6
+     * The ASF licenses this file to You under the Apache License, Version 2.0
7
+     * (the "License"); you may not use this file except in compliance with
8
+     * the License. You may obtain a copy of the License at
9
+     *
10
+     *	   http://www.apache.org/licenses/LICENSE-2.0
11
+     *
12
+     * Unless required by applicable law or agreed to in writing, software
13
+     * distributed under the License is distributed on an "AS IS" BASIS,
14
+     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+     * See the License for the specific language governing permissions and
16
+     * limitations under the License.
17
+     *
18
+     * @package log4php
19
+     */
20 20
 
21 21
 /**
22 22
  * LoggerConfiguratorPhp class
@@ -38,97 +38,97 @@  discard block
 block discarded – undo
38 38
  */
39 39
 class LoggerConfiguratorPhp implements LoggerConfigurator {
40 40
 	
41
-	public function configure(LoggerHierarchy $hierarchy, $url = '') {
42
-		return $this->doConfigure($url, $hierarchy);
43
-	}
41
+    public function configure(LoggerHierarchy $hierarchy, $url = '') {
42
+        return $this->doConfigure($url, $hierarchy);
43
+    }
44 44
 	
45
-	private function doConfigure($url, LoggerHierarchy $hierarchy) {
45
+    private function doConfigure($url, LoggerHierarchy $hierarchy) {
46 46
 		
47
-		$config = require $url;
47
+        $config = require $url;
48 48
 		
49
-		// set threshold
50
-		if(isset($config['threshold'])) {
51
-			$hierarchy->setThreshold(LoggerOptionConverter::toLevel($config['threshold'], LoggerLevel::getLevelAll()));
52
-		}
49
+        // set threshold
50
+        if(isset($config['threshold'])) {
51
+            $hierarchy->setThreshold(LoggerOptionConverter::toLevel($config['threshold'], LoggerLevel::getLevelAll()));
52
+        }
53 53
 		
54
-		// parse and create appenders
55
-		if(isset($config['appenders'])) {
54
+        // parse and create appenders
55
+        if(isset($config['appenders'])) {
56 56
 			
57
-			foreach($config['appenders'] as $appenderName => $appenderProperties) {
57
+            foreach($config['appenders'] as $appenderName => $appenderProperties) {
58 58
 				
59
-				$appender = LoggerAppenderPool::getAppenderFromPool($appenderName, $appenderProperties['class']);
59
+                $appender = LoggerAppenderPool::getAppenderFromPool($appenderName, $appenderProperties['class']);
60 60
 				
61
-				if($appender->requiresLayout()) {
61
+                if($appender->requiresLayout()) {
62 62
 					
63
-					if(isset($appenderProperties['layout'])) {
63
+                    if(isset($appenderProperties['layout'])) {
64 64
 						
65
-						if(isset($appenderProperties['layout']['class']) and !empty($appenderProperties['layout']['class'])) {
66
-							$layoutClass = $appenderProperties['layout']['class'];							
67
-						} else {
68
-							$layoutClass = 'LoggerLayoutSimple';
69
-						}
65
+                        if(isset($appenderProperties['layout']['class']) and !empty($appenderProperties['layout']['class'])) {
66
+                            $layoutClass = $appenderProperties['layout']['class'];							
67
+                        } else {
68
+                            $layoutClass = 'LoggerLayoutSimple';
69
+                        }
70 70
 						
71
-						$layout = LoggerReflectionUtils::createObject($layoutClass);
72
-						if($layout === null) {
73
-							$layout = LoggerReflectionUtils::createObject('LoggerLayoutSimple');
74
-						}
71
+                        $layout = LoggerReflectionUtils::createObject($layoutClass);
72
+                        if($layout === null) {
73
+                            $layout = LoggerReflectionUtils::createObject('LoggerLayoutSimple');
74
+                        }
75 75
 						
76
-						if($layout instanceof LoggerLayoutPattern) {
77
-							$layout->setConversionPattern($appenderProperties['layout']['conversionPattern']);
78
-						}
76
+                        if($layout instanceof LoggerLayoutPattern) {
77
+                            $layout->setConversionPattern($appenderProperties['layout']['conversionPattern']);
78
+                        }
79 79
 						
80
-						$appender->setLayout($layout);
80
+                        $appender->setLayout($layout);
81 81
 						
82
-					} else {
83
-						// TODO: throw exception?
84
-					}
82
+                    } else {
83
+                        // TODO: throw exception?
84
+                    }
85 85
 					
86
-				}
86
+                }
87 87
 				
88
-			}
88
+            }
89 89
 			
90
-		}
90
+        }
91 91
 		
92
-		// parse and create root logger
93
-		if(isset($config['rootLogger'])) {
94
-			$rootLogger = $hierarchy->getRootLogger();
95
-			if(isset($config['rootLogger']['level'])) {
96
-				$rootLogger->setLevel(LoggerOptionConverter::toLevel($config['rootLogger']['level'], LoggerLevel::getLevelDebug()));
97
-				if(isset($config['rootLogger']['appenders'])) {
98
-					foreach($config['rootLogger']['appenders'] as $appenderName) {
99
-						$appender = LoggerAppenderPool::getAppenderFromPool($appenderName);
100
-						if($appender !== null) {
101
-							$rootLogger->addAppender($appender);
102
-						}
103
-					}
104
-				}	
105
-			}
106
-		}
92
+        // parse and create root logger
93
+        if(isset($config['rootLogger'])) {
94
+            $rootLogger = $hierarchy->getRootLogger();
95
+            if(isset($config['rootLogger']['level'])) {
96
+                $rootLogger->setLevel(LoggerOptionConverter::toLevel($config['rootLogger']['level'], LoggerLevel::getLevelDebug()));
97
+                if(isset($config['rootLogger']['appenders'])) {
98
+                    foreach($config['rootLogger']['appenders'] as $appenderName) {
99
+                        $appender = LoggerAppenderPool::getAppenderFromPool($appenderName);
100
+                        if($appender !== null) {
101
+                            $rootLogger->addAppender($appender);
102
+                        }
103
+                    }
104
+                }	
105
+            }
106
+        }
107 107
 		
108
-		// parse and create loggers
109
-		if(isset($config['loggers'])) {
110
-			foreach($config['loggers'] as $loggerName => $loggerProperties) {
111
-				if(is_string($loggerName)) {
112
-					$logger = $hierarchy->getLogger($loggerName);
108
+        // parse and create loggers
109
+        if(isset($config['loggers'])) {
110
+            foreach($config['loggers'] as $loggerName => $loggerProperties) {
111
+                if(is_string($loggerName)) {
112
+                    $logger = $hierarchy->getLogger($loggerName);
113 113
 					
114
-					if(isset($loggerProperties['level'])) {
115
-						$logger->setLevel(LoggerOptionConverter::toLevel($loggerProperties['level'], LoggerLevel::getLevelDebug()));
116
-						if(isset($loggerProperties['appenders'])) {
117
-							foreach($loggerProperties['appenders'] as $appenderName) {
118
-								$appender = LoggerAppenderPool::getAppenderFromPool($appenderName);
119
-								if($appender !== null) {
120
-									$logger->addAppender($appender);
121
-								}
122
-							}
123
-						}	
124
-					}
125
-				} else {
126
-					// TODO: throw exception
127
-				}
128
-			}
129
-		}
114
+                    if(isset($loggerProperties['level'])) {
115
+                        $logger->setLevel(LoggerOptionConverter::toLevel($loggerProperties['level'], LoggerLevel::getLevelDebug()));
116
+                        if(isset($loggerProperties['appenders'])) {
117
+                            foreach($loggerProperties['appenders'] as $appenderName) {
118
+                                $appender = LoggerAppenderPool::getAppenderFromPool($appenderName);
119
+                                if($appender !== null) {
120
+                                    $logger->addAppender($appender);
121
+                                }
122
+                            }
123
+                        }	
124
+                    }
125
+                } else {
126
+                    // TODO: throw exception
127
+                }
128
+            }
129
+        }
130 130
 		
131
-		return true;
132
-	}
131
+        return true;
132
+    }
133 133
 	
134 134
 }
Please login to merge, or discard this patch.
main/inc/lib/phpdocx/lib/log4php/configurators/LoggerConfiguratorBasic.php 1 patch
Indentation   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -31,17 +31,17 @@
 block discarded – undo
31 31
  */
32 32
 class LoggerConfiguratorBasic implements LoggerConfigurator {
33 33
 
34
-	/**
35
-	 * Add a {@link LoggerAppenderConsole} that uses 
36
-	 * the {@link LoggerLayoutTTCC} to the root category.
37
-	 * 
38
-	 * @param string $url not used here
39
-	 */
40
-	public function configure(LoggerHierarchy $hierarchy, $url = null) {
41
-		$root = $hierarchy->getRootLogger();
42
-		$appender = new LoggerAppenderConsole('A1');
43
-		$appender->setLayout( new LoggerLayoutTTCC() );
44
-		$appender->activateOptions();
45
-		$root->addAppender($appender);
46
-	}
34
+    /**
35
+     * Add a {@link LoggerAppenderConsole} that uses 
36
+     * the {@link LoggerLayoutTTCC} to the root category.
37
+     * 
38
+     * @param string $url not used here
39
+     */
40
+    public function configure(LoggerHierarchy $hierarchy, $url = null) {
41
+        $root = $hierarchy->getRootLogger();
42
+        $appender = new LoggerAppenderConsole('A1');
43
+        $appender->setLayout( new LoggerLayoutTTCC() );
44
+        $appender->activateOptions();
45
+        $root->addAppender($appender);
46
+    }
47 47
 }
Please login to merge, or discard this patch.