This file is indexed.

/usr/share/php/phpdocx/lib/log4php/pattern/LoggerPatternConverter.php is in php-phpdocx 3.0+dfsg-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
<?php
/**
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements. See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License. You may obtain a copy of the License at
 *
 *	   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 * @package log4php
 */

/**
 * LoggerPatternConverter is an abstract class that provides the formatting 
 * functionality that derived classes need.
 * 
 * <p>Conversion specifiers in a conversion patterns are parsed to
 * individual PatternConverters. Each of which is responsible for
 * converting a logging event in a converter specific manner.</p>
 * 
 * @version $Revision: 1326626 $
 * @package log4php
 * @subpackage helpers
 * @since 0.3
 */
abstract class LoggerPatternConverter {
	
	/**
	 * Next converter in the converter chain.
	 * @var LoggerPatternConverter 
	 */
	public $next = null;
	
	/**
	 * Formatting information, parsed from pattern modifiers. 
	 * @var LoggerFormattingInfo
	 */
	protected $formattingInfo;
	
	/**
	 * Converter-specific formatting options.
	 * @var array
	 */
	protected $option;

	/**
	 * Constructor 
	 * @param LoggerFormattingInfo $formattingInfo
	 * @param array $option
	 */
	public function __construct(LoggerFormattingInfo $formattingInfo = null, $option = null) {  
		$this->formattingInfo = $formattingInfo;
		$this->option = $option;
		$this->activateOptions();
	}
	
	/**
	 * Called in constructor. Converters which need to process the options 
	 * can override this method. 
	 */
	public function activateOptions() { }
  
	/**
	 * Converts the logging event to the desired format. Derived pattern 
	 * converters must implement this method.
	 *
	 * @param LoggerLoggingEvent $event
	 */
	abstract public function convert(LoggerLoggingEvent $event);

	/**
	 * Converts the event and formats it according to setting in the 
	 * Formatting information object.
	 *
	 * @param string &$sbuf string buffer to write to
	 * @param LoggerLoggingEvent $event Event to be formatted.
	 */
	public function format(&$sbuf, $event) {
		$string = $this->convert($event);
		
		if (!isset($this->formattingInfo)) {
			$sbuf .= $string;
			return;	
		}
		
		$fi = $this->formattingInfo;
		
		// Empty string
		if($string === '' || is_null($string)) {
			if($fi->min > 0) {
				$sbuf .= str_repeat(' ', $fi->min);
			}
			return;
		}
		
		$len = strlen($string);
	
		// Trim the string if needed
		if($len > $fi->max) {
			if ($fi->trimLeft) {
				$sbuf .= substr($string, $len - $fi->max, $fi->max);
			} else {
				$sbuf .= substr($string , 0, $fi->max);
			}
		}
		
		// Add padding if needed
		else if($len < $fi->min) {
			if($fi->padLeft) {
				$sbuf .= str_repeat(' ', $fi->min - $len);
				$sbuf .= $string;
			} else {
				$sbuf .= $string;
				$sbuf .= str_repeat(' ', $fi->min - $len);
			}
		}
		
		// No action needed
		else {
			$sbuf .= $string;
		}
	}
}