@@ -27,97 +27,97 @@ |
||
| 27 | 27 | */ |
| 28 | 28 | class Payone_Log4php_LoggerUtils { |
| 29 | 29 | |
| 30 | - /** |
|
| 31 | - * Splits a fully qualified class name into fragments delimited by the |
|
| 32 | - * namespace separator (\). |
|
| 33 | - * |
|
| 34 | - * For backward compatibility, a dot (.) can be used as a delimiter as |
|
| 35 | - * well. |
|
| 36 | - * |
|
| 37 | - * @param string $name |
|
| 38 | - * |
|
| 39 | - * @return array Class name split into fragments. |
|
| 40 | - */ |
|
| 41 | - public static function tokenizeClassName($name) { |
|
| 42 | - $name = str_replace('.', '\\', $name); |
|
| 43 | - $name = trim($name, ' \\'); |
|
| 44 | - $fragments = explode('\\', $name); |
|
| 30 | + /** |
|
| 31 | + * Splits a fully qualified class name into fragments delimited by the |
|
| 32 | + * namespace separator (\). |
|
| 33 | + * |
|
| 34 | + * For backward compatibility, a dot (.) can be used as a delimiter as |
|
| 35 | + * well. |
|
| 36 | + * |
|
| 37 | + * @param string $name |
|
| 38 | + * |
|
| 39 | + * @return array Class name split into fragments. |
|
| 40 | + */ |
|
| 41 | + public static function tokenizeClassName($name) { |
|
| 42 | + $name = str_replace('.', '\\', $name); |
|
| 43 | + $name = trim($name, ' \\'); |
|
| 44 | + $fragments = explode('\\', $name); |
|
| 45 | 45 | |
| 46 | - foreach($fragments as $key => $fragment) { |
|
| 47 | - if (trim($fragment) === '') { |
|
| 48 | - unset($fragments[$key]); |
|
| 49 | - } |
|
| 50 | - } |
|
| 46 | + foreach($fragments as $key => $fragment) { |
|
| 47 | + if (trim($fragment) === '') { |
|
| 48 | + unset($fragments[$key]); |
|
| 49 | + } |
|
| 50 | + } |
|
| 51 | 51 | |
| 52 | - return $fragments; |
|
| 53 | - } |
|
| 52 | + return $fragments; |
|
| 53 | + } |
|
| 54 | 54 | |
| 55 | - /** |
|
| 56 | - * Attempts to shorten the given class name to the desired length. |
|
| 57 | - * |
|
| 58 | - * This is done by separating the class name into fragments (delimited |
|
| 59 | - * by \ or .) and trimming individual fragments, starting with the left, |
|
| 60 | - * until desired length has been reached. |
|
| 61 | - * |
|
| 62 | - * The final fragment (i.e. class name) will never be shortened so the |
|
| 63 | - * result may still be longer than given length. |
|
| 64 | - * |
|
| 65 | - * @param string $name The (qualified) class name. |
|
| 66 | - * @param integer $length The length to shorten to. If null or 0 is given, |
|
| 67 | - * the name will be returned without shortening. |
|
| 68 | - */ |
|
| 69 | - public static function shortenClassName($name, $length) { |
|
| 70 | - if ($length === null || $length < 0) { |
|
| 71 | - return $name; |
|
| 72 | - } |
|
| 55 | + /** |
|
| 56 | + * Attempts to shorten the given class name to the desired length. |
|
| 57 | + * |
|
| 58 | + * This is done by separating the class name into fragments (delimited |
|
| 59 | + * by \ or .) and trimming individual fragments, starting with the left, |
|
| 60 | + * until desired length has been reached. |
|
| 61 | + * |
|
| 62 | + * The final fragment (i.e. class name) will never be shortened so the |
|
| 63 | + * result may still be longer than given length. |
|
| 64 | + * |
|
| 65 | + * @param string $name The (qualified) class name. |
|
| 66 | + * @param integer $length The length to shorten to. If null or 0 is given, |
|
| 67 | + * the name will be returned without shortening. |
|
| 68 | + */ |
|
| 69 | + public static function shortenClassName($name, $length) { |
|
| 70 | + if ($length === null || $length < 0) { |
|
| 71 | + return $name; |
|
| 72 | + } |
|
| 73 | 73 | |
| 74 | - $name = str_replace('.', '\\', $name); |
|
| 75 | - $name = trim($name, ' \\'); |
|
| 74 | + $name = str_replace('.', '\\', $name); |
|
| 75 | + $name = trim($name, ' \\'); |
|
| 76 | 76 | |
| 77 | - // Check if any shortening is required |
|
| 78 | - $currentLength = strlen($name); |
|
| 79 | - if ($currentLength <= $length) { |
|
| 80 | - return $name; |
|
| 81 | - } |
|
| 77 | + // Check if any shortening is required |
|
| 78 | + $currentLength = strlen($name); |
|
| 79 | + if ($currentLength <= $length) { |
|
| 80 | + return $name; |
|
| 81 | + } |
|
| 82 | 82 | |
| 83 | - // Split name into fragments |
|
| 84 | - $fragments = explode('\\', $name); |
|
| 83 | + // Split name into fragments |
|
| 84 | + $fragments = explode('\\', $name); |
|
| 85 | 85 | |
| 86 | - // If zero length is specified, return only last fragment |
|
| 87 | - if ($length == 0) { |
|
| 88 | - return array_pop($fragments); |
|
| 89 | - } |
|
| 86 | + // If zero length is specified, return only last fragment |
|
| 87 | + if ($length == 0) { |
|
| 88 | + return array_pop($fragments); |
|
| 89 | + } |
|
| 90 | 90 | |
| 91 | - // If the name splits to only one fragment, then it cannot be shortened |
|
| 92 | - $count = count($fragments); |
|
| 93 | - if ($count == 1) { |
|
| 94 | - return $name; |
|
| 95 | - } |
|
| 91 | + // If the name splits to only one fragment, then it cannot be shortened |
|
| 92 | + $count = count($fragments); |
|
| 93 | + if ($count == 1) { |
|
| 94 | + return $name; |
|
| 95 | + } |
|
| 96 | 96 | |
| 97 | - foreach($fragments as $key => &$fragment) { |
|
| 97 | + foreach($fragments as $key => &$fragment) { |
|
| 98 | 98 | |
| 99 | - // Never shorten last fragment |
|
| 100 | - if ($key == $count - 1) { |
|
| 101 | - break; |
|
| 102 | - } |
|
| 99 | + // Never shorten last fragment |
|
| 100 | + if ($key == $count - 1) { |
|
| 101 | + break; |
|
| 102 | + } |
|
| 103 | 103 | |
| 104 | - // Check for empty fragments (shouldn't happen but it's possible) |
|
| 105 | - $fragLen = strlen($fragment); |
|
| 106 | - if ($fragLen <= 1) { |
|
| 107 | - continue; |
|
| 108 | - } |
|
| 104 | + // Check for empty fragments (shouldn't happen but it's possible) |
|
| 105 | + $fragLen = strlen($fragment); |
|
| 106 | + if ($fragLen <= 1) { |
|
| 107 | + continue; |
|
| 108 | + } |
|
| 109 | 109 | |
| 110 | - // Shorten fragment to one character and check if total length satisfactory |
|
| 111 | - $fragment = substr($fragment, 0, 1); |
|
| 112 | - $currentLength = $currentLength - $fragLen + 1; |
|
| 110 | + // Shorten fragment to one character and check if total length satisfactory |
|
| 111 | + $fragment = substr($fragment, 0, 1); |
|
| 112 | + $currentLength = $currentLength - $fragLen + 1; |
|
| 113 | 113 | |
| 114 | - if ($currentLength <= $length) { |
|
| 115 | - break; |
|
| 116 | - } |
|
| 117 | - } |
|
| 118 | - unset($fragment); |
|
| 114 | + if ($currentLength <= $length) { |
|
| 115 | + break; |
|
| 116 | + } |
|
| 117 | + } |
|
| 118 | + unset($fragment); |
|
| 119 | 119 | |
| 120 | - return implode('\\', $fragments); |
|
| 121 | - } |
|
| 120 | + return implode('\\', $fragments); |
|
| 121 | + } |
|
| 122 | 122 | } |
| 123 | 123 | |
@@ -43,7 +43,7 @@ discard block |
||
| 43 | 43 | $name = trim($name, ' \\'); |
| 44 | 44 | $fragments = explode('\\', $name); |
| 45 | 45 | |
| 46 | - foreach($fragments as $key => $fragment) { |
|
| 46 | + foreach ($fragments as $key => $fragment) { |
|
| 47 | 47 | if (trim($fragment) === '') { |
| 48 | 48 | unset($fragments[$key]); |
| 49 | 49 | } |
@@ -94,7 +94,7 @@ discard block |
||
| 94 | 94 | return $name; |
| 95 | 95 | } |
| 96 | 96 | |
| 97 | - foreach($fragments as $key => &$fragment) { |
|
| 97 | + foreach ($fragments as $key => &$fragment) { |
|
| 98 | 98 | |
| 99 | 99 | // Never shorten last fragment |
| 100 | 100 | if ($key == $count - 1) { |
@@ -43,63 +43,63 @@ |
||
| 43 | 43 | */ |
| 44 | 44 | class Payone_Log4php_LoggerAppenderConsole extends Payone_Log4php_LoggerAppender { |
| 45 | 45 | |
| 46 | - const STDOUT = 'php://stdout'; |
|
| 47 | - const STDERR = 'php://stderr'; |
|
| 46 | + const STDOUT = 'php://stdout'; |
|
| 47 | + const STDERR = 'php://stderr'; |
|
| 48 | 48 | |
| 49 | - /** |
|
| 50 | - * Can be 'php://stdout' or 'php://stderr'. But it's better to use keywords <b>STDOUT</b> and <b>STDERR</b> (case insensitive). |
|
| 51 | - * Default is STDOUT |
|
| 52 | - * @var string |
|
| 53 | - */ |
|
| 54 | - protected $target = self::STDOUT; |
|
| 49 | + /** |
|
| 50 | + * Can be 'php://stdout' or 'php://stderr'. But it's better to use keywords <b>STDOUT</b> and <b>STDERR</b> (case insensitive). |
|
| 51 | + * Default is STDOUT |
|
| 52 | + * @var string |
|
| 53 | + */ |
|
| 54 | + protected $target = self::STDOUT; |
|
| 55 | 55 | |
| 56 | - /** |
|
| 57 | - * @var mixed the resource used to open stdout/stderr |
|
| 58 | - */ |
|
| 59 | - protected $fp = null; |
|
| 56 | + /** |
|
| 57 | + * @var mixed the resource used to open stdout/stderr |
|
| 58 | + */ |
|
| 59 | + protected $fp = null; |
|
| 60 | 60 | |
| 61 | - /** |
|
| 62 | - * Set console target. |
|
| 63 | - * @param mixed $value a constant or a string |
|
| 64 | - */ |
|
| 65 | - public function setTarget($value) { |
|
| 66 | - $v = trim($value); |
|
| 67 | - if ($v == self::STDOUT || strtoupper($v) == 'STDOUT') { |
|
| 68 | - $this->target = self::STDOUT; |
|
| 69 | - } elseif ($v == self::STDERR || strtoupper($v) == 'STDERR') { |
|
| 70 | - $this->target = self::STDERR; |
|
| 71 | - } else { |
|
| 72 | - $value = var_export($value); |
|
| 73 | - $this->warn("Invalid value given for 'target' property: [$value]. Property not set."); |
|
| 74 | - } |
|
| 75 | - } |
|
| 61 | + /** |
|
| 62 | + * Set console target. |
|
| 63 | + * @param mixed $value a constant or a string |
|
| 64 | + */ |
|
| 65 | + public function setTarget($value) { |
|
| 66 | + $v = trim($value); |
|
| 67 | + if ($v == self::STDOUT || strtoupper($v) == 'STDOUT') { |
|
| 68 | + $this->target = self::STDOUT; |
|
| 69 | + } elseif ($v == self::STDERR || strtoupper($v) == 'STDERR') { |
|
| 70 | + $this->target = self::STDERR; |
|
| 71 | + } else { |
|
| 72 | + $value = var_export($value); |
|
| 73 | + $this->warn("Invalid value given for 'target' property: [$value]. Property not set."); |
|
| 74 | + } |
|
| 75 | + } |
|
| 76 | 76 | |
| 77 | - public function getTarget() { |
|
| 78 | - return $this->target; |
|
| 79 | - } |
|
| 77 | + public function getTarget() { |
|
| 78 | + return $this->target; |
|
| 79 | + } |
|
| 80 | 80 | |
| 81 | - public function activateOptions() { |
|
| 82 | - $this->fp = fopen($this->target, 'w'); |
|
| 83 | - if(is_resource($this->fp) && $this->layout !== null) { |
|
| 84 | - fwrite($this->fp, $this->layout->getHeader()); |
|
| 85 | - } |
|
| 86 | - $this->closed = (bool)is_resource($this->fp) === false; |
|
| 87 | - } |
|
| 81 | + public function activateOptions() { |
|
| 82 | + $this->fp = fopen($this->target, 'w'); |
|
| 83 | + if(is_resource($this->fp) && $this->layout !== null) { |
|
| 84 | + fwrite($this->fp, $this->layout->getHeader()); |
|
| 85 | + } |
|
| 86 | + $this->closed = (bool)is_resource($this->fp) === false; |
|
| 87 | + } |
|
| 88 | 88 | |
| 89 | - public function close() { |
|
| 90 | - if($this->closed != true) { |
|
| 91 | - if (is_resource($this->fp) && $this->layout !== null) { |
|
| 92 | - fwrite($this->fp, $this->layout->getFooter()); |
|
| 93 | - fclose($this->fp); |
|
| 94 | - } |
|
| 95 | - $this->closed = true; |
|
| 96 | - } |
|
| 97 | - } |
|
| 89 | + public function close() { |
|
| 90 | + if($this->closed != true) { |
|
| 91 | + if (is_resource($this->fp) && $this->layout !== null) { |
|
| 92 | + fwrite($this->fp, $this->layout->getFooter()); |
|
| 93 | + fclose($this->fp); |
|
| 94 | + } |
|
| 95 | + $this->closed = true; |
|
| 96 | + } |
|
| 97 | + } |
|
| 98 | 98 | |
| 99 | - public function append(Payone_Log4php_LoggerLoggingEvent $event) { |
|
| 100 | - if (is_resource($this->fp) && $this->layout !== null) { |
|
| 101 | - fwrite($this->fp, $this->layout->format($event)); |
|
| 102 | - } |
|
| 103 | - } |
|
| 99 | + public function append(Payone_Log4php_LoggerLoggingEvent $event) { |
|
| 100 | + if (is_resource($this->fp) && $this->layout !== null) { |
|
| 101 | + fwrite($this->fp, $this->layout->format($event)); |
|
| 102 | + } |
|
| 103 | + } |
|
| 104 | 104 | } |
| 105 | 105 | |
@@ -80,14 +80,14 @@ |
||
| 80 | 80 | |
| 81 | 81 | public function activateOptions() { |
| 82 | 82 | $this->fp = fopen($this->target, 'w'); |
| 83 | - if(is_resource($this->fp) && $this->layout !== null) { |
|
| 83 | + if (is_resource($this->fp) && $this->layout !== null) { |
|
| 84 | 84 | fwrite($this->fp, $this->layout->getHeader()); |
| 85 | 85 | } |
| 86 | 86 | $this->closed = (bool)is_resource($this->fp) === false; |
| 87 | 87 | } |
| 88 | 88 | |
| 89 | 89 | public function close() { |
| 90 | - if($this->closed != true) { |
|
| 90 | + if ($this->closed != true) { |
|
| 91 | 91 | if (is_resource($this->fp) && $this->layout !== null) { |
| 92 | 92 | fwrite($this->fp, $this->layout->getFooter()); |
| 93 | 93 | fclose($this->fp); |
@@ -48,184 +48,184 @@ |
||
| 48 | 48 | */ |
| 49 | 49 | class Payone_Log4php_LoggerAppenderRollingFile extends Payone_Log4php_LoggerAppenderFile { |
| 50 | 50 | |
| 51 | - /** |
|
| 52 | - * Set the maximum size that the output file is allowed to reach |
|
| 53 | - * before being rolled over to backup files. |
|
| 54 | - * |
|
| 55 | - * <p>In configuration files, the <var>MaxFileSize</var> option takes a |
|
| 56 | - * long integer in the range 0 - 2^63. You can specify the value |
|
| 57 | - * with the suffixes "KB", "MB" or "GB" so that the integer is |
|
| 58 | - * interpreted being expressed respectively in kilobytes, megabytes |
|
| 59 | - * or gigabytes. For example, the value "10KB" will be interpreted |
|
| 60 | - * as 10240.</p> |
|
| 61 | - * <p>The default maximum file size is 10MB.</p> |
|
| 62 | - * |
|
| 63 | - * <p>Note that MaxFileSize cannot exceed <b>2 GB</b>.</p> |
|
| 64 | - * |
|
| 65 | - * @var integer |
|
| 66 | - */ |
|
| 67 | - protected $maxFileSize = 10485760; |
|
| 51 | + /** |
|
| 52 | + * Set the maximum size that the output file is allowed to reach |
|
| 53 | + * before being rolled over to backup files. |
|
| 54 | + * |
|
| 55 | + * <p>In configuration files, the <var>MaxFileSize</var> option takes a |
|
| 56 | + * long integer in the range 0 - 2^63. You can specify the value |
|
| 57 | + * with the suffixes "KB", "MB" or "GB" so that the integer is |
|
| 58 | + * interpreted being expressed respectively in kilobytes, megabytes |
|
| 59 | + * or gigabytes. For example, the value "10KB" will be interpreted |
|
| 60 | + * as 10240.</p> |
|
| 61 | + * <p>The default maximum file size is 10MB.</p> |
|
| 62 | + * |
|
| 63 | + * <p>Note that MaxFileSize cannot exceed <b>2 GB</b>.</p> |
|
| 64 | + * |
|
| 65 | + * @var integer |
|
| 66 | + */ |
|
| 67 | + protected $maxFileSize = 10485760; |
|
| 68 | 68 | |
| 69 | - /** |
|
| 70 | - * Set the maximum number of backup files to keep around. |
|
| 71 | - * |
|
| 72 | - * <p>The <var>MaxBackupIndex</var> option determines how many backup |
|
| 73 | - * files are kept before the oldest is erased. This option takes |
|
| 74 | - * a positive integer value. If set to zero, then there will be no |
|
| 75 | - * backup files and the log file will be truncated when it reaches |
|
| 76 | - * MaxFileSize.</p> |
|
| 77 | - * <p>There is one backup file by default.</p> |
|
| 78 | - * |
|
| 79 | - * @var integer |
|
| 80 | - */ |
|
| 81 | - protected $maxBackupIndex = 1; |
|
| 69 | + /** |
|
| 70 | + * Set the maximum number of backup files to keep around. |
|
| 71 | + * |
|
| 72 | + * <p>The <var>MaxBackupIndex</var> option determines how many backup |
|
| 73 | + * files are kept before the oldest is erased. This option takes |
|
| 74 | + * a positive integer value. If set to zero, then there will be no |
|
| 75 | + * backup files and the log file will be truncated when it reaches |
|
| 76 | + * MaxFileSize.</p> |
|
| 77 | + * <p>There is one backup file by default.</p> |
|
| 78 | + * |
|
| 79 | + * @var integer |
|
| 80 | + */ |
|
| 81 | + protected $maxBackupIndex = 1; |
|
| 82 | 82 | |
| 83 | - /** |
|
| 84 | - * @var string the filename expanded |
|
| 85 | - */ |
|
| 86 | - private $expandedFileName = null; |
|
| 83 | + /** |
|
| 84 | + * @var string the filename expanded |
|
| 85 | + */ |
|
| 86 | + private $expandedFileName = null; |
|
| 87 | 87 | |
| 88 | - /** |
|
| 89 | - * Returns the value of the MaxBackupIndex option. |
|
| 90 | - * @return integer |
|
| 91 | - */ |
|
| 92 | - private function getExpandedFileName() { |
|
| 93 | - return $this->expandedFileName; |
|
| 94 | - } |
|
| 88 | + /** |
|
| 89 | + * Returns the value of the MaxBackupIndex option. |
|
| 90 | + * @return integer |
|
| 91 | + */ |
|
| 92 | + private function getExpandedFileName() { |
|
| 93 | + return $this->expandedFileName; |
|
| 94 | + } |
|
| 95 | 95 | |
| 96 | - /** |
|
| 97 | - * Get the maximum size that the output file is allowed to reach |
|
| 98 | - * before being rolled over to backup files. |
|
| 99 | - * @return integer |
|
| 100 | - */ |
|
| 101 | - public function getMaximumFileSize() { |
|
| 102 | - return $this->maxFileSize; |
|
| 103 | - } |
|
| 96 | + /** |
|
| 97 | + * Get the maximum size that the output file is allowed to reach |
|
| 98 | + * before being rolled over to backup files. |
|
| 99 | + * @return integer |
|
| 100 | + */ |
|
| 101 | + public function getMaximumFileSize() { |
|
| 102 | + return $this->maxFileSize; |
|
| 103 | + } |
|
| 104 | 104 | |
| 105 | - /** |
|
| 106 | - * Implements the usual roll over behaviour. |
|
| 107 | - * |
|
| 108 | - * <p>If MaxBackupIndex is positive, then files File.1, ..., File.MaxBackupIndex -1 are renamed to File.2, ..., File.MaxBackupIndex. |
|
| 109 | - * Moreover, File is renamed File.1 and closed. A new File is created to receive further log output. |
|
| 110 | - * |
|
| 111 | - * <p>If MaxBackupIndex is equal to zero, then the File is truncated with no backup files created. |
|
| 112 | - * |
|
| 113 | - * Rollover must be called while the file is locked so that it is safe for concurrent access. |
|
| 114 | - */ |
|
| 115 | - private function rollOver() { |
|
| 116 | - // If maxBackups <= 0, then there is no file renaming to be done. |
|
| 117 | - if($this->maxBackupIndex > 0) { |
|
| 118 | - $fileName = $this->getExpandedFileName(); |
|
| 105 | + /** |
|
| 106 | + * Implements the usual roll over behaviour. |
|
| 107 | + * |
|
| 108 | + * <p>If MaxBackupIndex is positive, then files File.1, ..., File.MaxBackupIndex -1 are renamed to File.2, ..., File.MaxBackupIndex. |
|
| 109 | + * Moreover, File is renamed File.1 and closed. A new File is created to receive further log output. |
|
| 110 | + * |
|
| 111 | + * <p>If MaxBackupIndex is equal to zero, then the File is truncated with no backup files created. |
|
| 112 | + * |
|
| 113 | + * Rollover must be called while the file is locked so that it is safe for concurrent access. |
|
| 114 | + */ |
|
| 115 | + private function rollOver() { |
|
| 116 | + // If maxBackups <= 0, then there is no file renaming to be done. |
|
| 117 | + if($this->maxBackupIndex > 0) { |
|
| 118 | + $fileName = $this->getExpandedFileName(); |
|
| 119 | 119 | |
| 120 | - // Delete the oldest file, to keep Windows happy. |
|
| 121 | - $file = $fileName . '.' . $this->maxBackupIndex; |
|
| 122 | - if(is_writable($file)) |
|
| 123 | - unlink($file); |
|
| 120 | + // Delete the oldest file, to keep Windows happy. |
|
| 121 | + $file = $fileName . '.' . $this->maxBackupIndex; |
|
| 122 | + if(is_writable($file)) |
|
| 123 | + unlink($file); |
|
| 124 | 124 | |
| 125 | - // Map {(maxBackupIndex - 1), ..., 2, 1} to {maxBackupIndex, ..., 3, 2} |
|
| 126 | - for($i = $this->maxBackupIndex - 1; $i >= 1; $i--) { |
|
| 127 | - $file = $fileName . "." . $i; |
|
| 128 | - if(is_readable($file)) { |
|
| 129 | - $target = $fileName . '.' . ($i + 1); |
|
| 130 | - rename($file, $target); |
|
| 131 | - } |
|
| 132 | - } |
|
| 125 | + // Map {(maxBackupIndex - 1), ..., 2, 1} to {maxBackupIndex, ..., 3, 2} |
|
| 126 | + for($i = $this->maxBackupIndex - 1; $i >= 1; $i--) { |
|
| 127 | + $file = $fileName . "." . $i; |
|
| 128 | + if(is_readable($file)) { |
|
| 129 | + $target = $fileName . '.' . ($i + 1); |
|
| 130 | + rename($file, $target); |
|
| 131 | + } |
|
| 132 | + } |
|
| 133 | 133 | |
| 134 | - // Backup the active file |
|
| 135 | - copy($fileName, "$fileName.1"); |
|
| 136 | - } |
|
| 134 | + // Backup the active file |
|
| 135 | + copy($fileName, "$fileName.1"); |
|
| 136 | + } |
|
| 137 | 137 | |
| 138 | - // Truncate the active file |
|
| 139 | - ftruncate($this->fp, 0); |
|
| 140 | - rewind($this->fp); |
|
| 141 | - } |
|
| 138 | + // Truncate the active file |
|
| 139 | + ftruncate($this->fp, 0); |
|
| 140 | + rewind($this->fp); |
|
| 141 | + } |
|
| 142 | 142 | |
| 143 | - public function setFile($fileName) { |
|
| 144 | - $this->file = $fileName; |
|
| 145 | - // As Payone_Log4php_LoggerAppenderFile does not create the directory, it has to exist. |
|
| 146 | - // realpath() fails if the argument does not exist so the filename is separated. |
|
| 147 | - $this->expandedFileName = realpath(dirname($fileName)); |
|
| 148 | - if ($this->expandedFileName === false) throw new Exception("Directory of $fileName does not exist!"); |
|
| 149 | - $this->expandedFileName .= DIRECTORY_SEPARATOR . basename($fileName); |
|
| 150 | - } |
|
| 143 | + public function setFile($fileName) { |
|
| 144 | + $this->file = $fileName; |
|
| 145 | + // As Payone_Log4php_LoggerAppenderFile does not create the directory, it has to exist. |
|
| 146 | + // realpath() fails if the argument does not exist so the filename is separated. |
|
| 147 | + $this->expandedFileName = realpath(dirname($fileName)); |
|
| 148 | + if ($this->expandedFileName === false) throw new Exception("Directory of $fileName does not exist!"); |
|
| 149 | + $this->expandedFileName .= DIRECTORY_SEPARATOR . basename($fileName); |
|
| 150 | + } |
|
| 151 | 151 | |
| 152 | 152 | |
| 153 | - /** |
|
| 154 | - * Set the maximum number of backup files to keep around. |
|
| 155 | - * |
|
| 156 | - * <p>The <b>MaxBackupIndex</b> option determines how many backup |
|
| 157 | - * files are kept before the oldest is erased. This option takes |
|
| 158 | - * a positive integer value. If set to zero, then there will be no |
|
| 159 | - * backup files and the log file will be truncated when it reaches |
|
| 160 | - * MaxFileSize. |
|
| 161 | - * |
|
| 162 | - * @param mixed $maxBackups |
|
| 163 | - */ |
|
| 164 | - public function setMaxBackupIndex($maxBackups) { |
|
| 165 | - $this->setPositiveInteger('maxBackupIndex', $maxBackups); |
|
| 166 | - } |
|
| 153 | + /** |
|
| 154 | + * Set the maximum number of backup files to keep around. |
|
| 155 | + * |
|
| 156 | + * <p>The <b>MaxBackupIndex</b> option determines how many backup |
|
| 157 | + * files are kept before the oldest is erased. This option takes |
|
| 158 | + * a positive integer value. If set to zero, then there will be no |
|
| 159 | + * backup files and the log file will be truncated when it reaches |
|
| 160 | + * MaxFileSize. |
|
| 161 | + * |
|
| 162 | + * @param mixed $maxBackups |
|
| 163 | + */ |
|
| 164 | + public function setMaxBackupIndex($maxBackups) { |
|
| 165 | + $this->setPositiveInteger('maxBackupIndex', $maxBackups); |
|
| 166 | + } |
|
| 167 | 167 | |
| 168 | - /** |
|
| 169 | - * Set the maximum size that the output file is allowed to reach |
|
| 170 | - * before being rolled over to backup files. |
|
| 171 | - * |
|
| 172 | - * @param mixed $maxFileSize |
|
| 173 | - * @see setMaxFileSize() |
|
| 174 | - * @deprecated |
|
| 175 | - */ |
|
| 176 | - public function setMaximumFileSize($maxFileSize) { |
|
| 177 | - return $this->setMaxFileSize($maxFileSize); |
|
| 178 | - } |
|
| 168 | + /** |
|
| 169 | + * Set the maximum size that the output file is allowed to reach |
|
| 170 | + * before being rolled over to backup files. |
|
| 171 | + * |
|
| 172 | + * @param mixed $maxFileSize |
|
| 173 | + * @see setMaxFileSize() |
|
| 174 | + * @deprecated |
|
| 175 | + */ |
|
| 176 | + public function setMaximumFileSize($maxFileSize) { |
|
| 177 | + return $this->setMaxFileSize($maxFileSize); |
|
| 178 | + } |
|
| 179 | 179 | |
| 180 | - /** |
|
| 181 | - * Set the maximum size that the output file is allowed to reach |
|
| 182 | - * before being rolled over to backup files. |
|
| 183 | - * <p>In configuration files, the <b>maxFileSize</b> option takes an |
|
| 184 | - * long integer in the range 0 - 2^63. You can specify the value |
|
| 185 | - * with the suffixes "KB", "MB" or "GB" so that the integer is |
|
| 186 | - * interpreted being expressed respectively in kilobytes, megabytes |
|
| 187 | - * or gigabytes. For example, the value "10KB" will be interpreted |
|
| 188 | - * as 10240. |
|
| 189 | - * |
|
| 190 | - * @param mixed $value |
|
| 191 | - * @return the actual file size set |
|
| 192 | - */ |
|
| 193 | - public function setMaxFileSize($value) { |
|
| 194 | - $this->setFileSize('maxFileSize', $value); |
|
| 195 | - } |
|
| 180 | + /** |
|
| 181 | + * Set the maximum size that the output file is allowed to reach |
|
| 182 | + * before being rolled over to backup files. |
|
| 183 | + * <p>In configuration files, the <b>maxFileSize</b> option takes an |
|
| 184 | + * long integer in the range 0 - 2^63. You can specify the value |
|
| 185 | + * with the suffixes "KB", "MB" or "GB" so that the integer is |
|
| 186 | + * interpreted being expressed respectively in kilobytes, megabytes |
|
| 187 | + * or gigabytes. For example, the value "10KB" will be interpreted |
|
| 188 | + * as 10240. |
|
| 189 | + * |
|
| 190 | + * @param mixed $value |
|
| 191 | + * @return the actual file size set |
|
| 192 | + */ |
|
| 193 | + public function setMaxFileSize($value) { |
|
| 194 | + $this->setFileSize('maxFileSize', $value); |
|
| 195 | + } |
|
| 196 | 196 | |
| 197 | - public function append(Payone_Log4php_LoggerLoggingEvent $event) { |
|
| 198 | - if($this->fp and $this->layout !== null) { |
|
| 199 | - if(flock($this->fp, LOCK_EX)) { |
|
| 200 | - fwrite($this->fp, $this->layout->format($event)); |
|
| 197 | + public function append(Payone_Log4php_LoggerLoggingEvent $event) { |
|
| 198 | + if($this->fp and $this->layout !== null) { |
|
| 199 | + if(flock($this->fp, LOCK_EX)) { |
|
| 200 | + fwrite($this->fp, $this->layout->format($event)); |
|
| 201 | 201 | |
| 202 | - // Stats cache must be cleared, otherwise filesize() returns cached results |
|
| 203 | - clearstatcache(); |
|
| 202 | + // Stats cache must be cleared, otherwise filesize() returns cached results |
|
| 203 | + clearstatcache(); |
|
| 204 | 204 | |
| 205 | - // Rollover if needed |
|
| 206 | - if (filesize($this->expandedFileName) > $this->maxFileSize) { |
|
| 207 | - $this->rollOver(); |
|
| 208 | - } |
|
| 205 | + // Rollover if needed |
|
| 206 | + if (filesize($this->expandedFileName) > $this->maxFileSize) { |
|
| 207 | + $this->rollOver(); |
|
| 208 | + } |
|
| 209 | 209 | |
| 210 | - flock($this->fp, LOCK_UN); |
|
| 211 | - } else { |
|
| 212 | - $this->closed = true; |
|
| 213 | - } |
|
| 214 | - } |
|
| 215 | - } |
|
| 210 | + flock($this->fp, LOCK_UN); |
|
| 211 | + } else { |
|
| 212 | + $this->closed = true; |
|
| 213 | + } |
|
| 214 | + } |
|
| 215 | + } |
|
| 216 | 216 | |
| 217 | - /** |
|
| 218 | - * @return Returns the maximum number of backup files to keep around. |
|
| 219 | - */ |
|
| 220 | - public function getMaxBackupIndex() { |
|
| 221 | - return $this->maxBackupIndex; |
|
| 222 | - } |
|
| 217 | + /** |
|
| 218 | + * @return Returns the maximum number of backup files to keep around. |
|
| 219 | + */ |
|
| 220 | + public function getMaxBackupIndex() { |
|
| 221 | + return $this->maxBackupIndex; |
|
| 222 | + } |
|
| 223 | 223 | |
| 224 | - /** |
|
| 225 | - * @return Returns the maximum size that the output file is allowed to reach |
|
| 226 | - * before being rolled over to backup files. |
|
| 227 | - */ |
|
| 228 | - public function getMaxFileSize() { |
|
| 229 | - return $this->maxFileSize; |
|
| 230 | - } |
|
| 224 | + /** |
|
| 225 | + * @return Returns the maximum size that the output file is allowed to reach |
|
| 226 | + * before being rolled over to backup files. |
|
| 227 | + */ |
|
| 228 | + public function getMaxFileSize() { |
|
| 229 | + return $this->maxFileSize; |
|
| 230 | + } |
|
| 231 | 231 | } |
@@ -114,18 +114,18 @@ discard block |
||
| 114 | 114 | */ |
| 115 | 115 | private function rollOver() { |
| 116 | 116 | // If maxBackups <= 0, then there is no file renaming to be done. |
| 117 | - if($this->maxBackupIndex > 0) { |
|
| 117 | + if ($this->maxBackupIndex > 0) { |
|
| 118 | 118 | $fileName = $this->getExpandedFileName(); |
| 119 | 119 | |
| 120 | 120 | // Delete the oldest file, to keep Windows happy. |
| 121 | 121 | $file = $fileName . '.' . $this->maxBackupIndex; |
| 122 | - if(is_writable($file)) |
|
| 122 | + if (is_writable($file)) |
|
| 123 | 123 | unlink($file); |
| 124 | 124 | |
| 125 | 125 | // Map {(maxBackupIndex - 1), ..., 2, 1} to {maxBackupIndex, ..., 3, 2} |
| 126 | - for($i = $this->maxBackupIndex - 1; $i >= 1; $i--) { |
|
| 126 | + for ($i = $this->maxBackupIndex - 1; $i >= 1; $i--) { |
|
| 127 | 127 | $file = $fileName . "." . $i; |
| 128 | - if(is_readable($file)) { |
|
| 128 | + if (is_readable($file)) { |
|
| 129 | 129 | $target = $fileName . '.' . ($i + 1); |
| 130 | 130 | rename($file, $target); |
| 131 | 131 | } |
@@ -195,8 +195,8 @@ discard block |
||
| 195 | 195 | } |
| 196 | 196 | |
| 197 | 197 | public function append(Payone_Log4php_LoggerLoggingEvent $event) { |
| 198 | - if($this->fp and $this->layout !== null) { |
|
| 199 | - if(flock($this->fp, LOCK_EX)) { |
|
| 198 | + if ($this->fp and $this->layout !== null) { |
|
| 199 | + if (flock($this->fp, LOCK_EX)) { |
|
| 200 | 200 | fwrite($this->fp, $this->layout->format($event)); |
| 201 | 201 | |
| 202 | 202 | // Stats cache must be cleared, otherwise filesize() returns cached results |
@@ -119,8 +119,9 @@ discard block |
||
| 119 | 119 | |
| 120 | 120 | // Delete the oldest file, to keep Windows happy. |
| 121 | 121 | $file = $fileName . '.' . $this->maxBackupIndex; |
| 122 | - if(is_writable($file)) |
|
| 123 | - unlink($file); |
|
| 122 | + if(is_writable($file)) { |
|
| 123 | + unlink($file); |
|
| 124 | + } |
|
| 124 | 125 | |
| 125 | 126 | // Map {(maxBackupIndex - 1), ..., 2, 1} to {maxBackupIndex, ..., 3, 2} |
| 126 | 127 | for($i = $this->maxBackupIndex - 1; $i >= 1; $i--) { |
@@ -145,7 +146,9 @@ discard block |
||
| 145 | 146 | // As Payone_Log4php_LoggerAppenderFile does not create the directory, it has to exist. |
| 146 | 147 | // realpath() fails if the argument does not exist so the filename is separated. |
| 147 | 148 | $this->expandedFileName = realpath(dirname($fileName)); |
| 148 | - if ($this->expandedFileName === false) throw new Exception("Directory of $fileName does not exist!"); |
|
| 149 | + if ($this->expandedFileName === false) { |
|
| 150 | + throw new Exception("Directory of $fileName does not exist!"); |
|
| 151 | + } |
|
| 149 | 152 | $this->expandedFileName .= DIRECTORY_SEPARATOR . basename($fileName); |
| 150 | 153 | } |
| 151 | 154 | |
@@ -73,233 +73,233 @@ |
||
| 73 | 73 | */ |
| 74 | 74 | class Payone_Log4php_LoggerAppenderSyslog extends Payone_Log4php_LoggerAppender { |
| 75 | 75 | |
| 76 | - /** |
|
| 77 | - * The ident string is added to each message. Typically the name of your application. |
|
| 78 | - * |
|
| 79 | - * @var string |
|
| 80 | - */ |
|
| 81 | - protected $ident = "Apache log4php"; |
|
| 76 | + /** |
|
| 77 | + * The ident string is added to each message. Typically the name of your application. |
|
| 78 | + * |
|
| 79 | + * @var string |
|
| 80 | + */ |
|
| 81 | + protected $ident = "Apache log4php"; |
|
| 82 | 82 | |
| 83 | - /** |
|
| 84 | - * The syslog priority to use when overriding priority. This setting is |
|
| 85 | - * required if {@link overridePriority} is set to true. |
|
| 86 | - * |
|
| 87 | - * @var string |
|
| 88 | - */ |
|
| 89 | - protected $priority; |
|
| 83 | + /** |
|
| 84 | + * The syslog priority to use when overriding priority. This setting is |
|
| 85 | + * required if {@link overridePriority} is set to true. |
|
| 86 | + * |
|
| 87 | + * @var string |
|
| 88 | + */ |
|
| 89 | + protected $priority; |
|
| 90 | 90 | |
| 91 | - /** |
|
| 92 | - * The option used when opening the syslog connection. |
|
| 93 | - * |
|
| 94 | - * @var string |
|
| 95 | - */ |
|
| 96 | - protected $option = 'PID|CONS'; |
|
| 91 | + /** |
|
| 92 | + * The option used when opening the syslog connection. |
|
| 93 | + * |
|
| 94 | + * @var string |
|
| 95 | + */ |
|
| 96 | + protected $option = 'PID|CONS'; |
|
| 97 | 97 | |
| 98 | - /** |
|
| 99 | - * The facility value indicates the source of the message. |
|
| 100 | - * |
|
| 101 | - * @var string |
|
| 102 | - */ |
|
| 103 | - protected $facility = 'USER'; |
|
| 98 | + /** |
|
| 99 | + * The facility value indicates the source of the message. |
|
| 100 | + * |
|
| 101 | + * @var string |
|
| 102 | + */ |
|
| 103 | + protected $facility = 'USER'; |
|
| 104 | 104 | |
| 105 | - /** |
|
| 106 | - * If set to true, the message priority will always use the value defined |
|
| 107 | - * in {@link $priority}, otherwise the priority will be determined by the |
|
| 108 | - * message's log level. |
|
| 109 | - * |
|
| 110 | - * @var string |
|
| 111 | - */ |
|
| 112 | - protected $overridePriority = false; |
|
| 105 | + /** |
|
| 106 | + * If set to true, the message priority will always use the value defined |
|
| 107 | + * in {@link $priority}, otherwise the priority will be determined by the |
|
| 108 | + * message's log level. |
|
| 109 | + * |
|
| 110 | + * @var string |
|
| 111 | + */ |
|
| 112 | + protected $overridePriority = false; |
|
| 113 | 113 | |
| 114 | - /** |
|
| 115 | - * Holds the int value of the {@link $priority}. |
|
| 116 | - * @var int |
|
| 117 | - */ |
|
| 118 | - private $intPriority; |
|
| 114 | + /** |
|
| 115 | + * Holds the int value of the {@link $priority}. |
|
| 116 | + * @var int |
|
| 117 | + */ |
|
| 118 | + private $intPriority; |
|
| 119 | 119 | |
| 120 | - /** |
|
| 121 | - * Holds the int value of the {@link $facility}. |
|
| 122 | - * @var int |
|
| 123 | - */ |
|
| 124 | - private $intFacility; |
|
| 120 | + /** |
|
| 121 | + * Holds the int value of the {@link $facility}. |
|
| 122 | + * @var int |
|
| 123 | + */ |
|
| 124 | + private $intFacility; |
|
| 125 | 125 | |
| 126 | - /** |
|
| 127 | - * Holds the int value of the {@link $option}. |
|
| 128 | - * @var int |
|
| 129 | - */ |
|
| 130 | - private $intOption; |
|
| 126 | + /** |
|
| 127 | + * Holds the int value of the {@link $option}. |
|
| 128 | + * @var int |
|
| 129 | + */ |
|
| 130 | + private $intOption; |
|
| 131 | 131 | |
| 132 | - /** |
|
| 133 | - * Sets the {@link $ident}. |
|
| 134 | - * |
|
| 135 | - * @param string $ident |
|
| 136 | - */ |
|
| 137 | - public function setIdent($ident) { |
|
| 138 | - $this->ident = $ident; |
|
| 139 | - } |
|
| 132 | + /** |
|
| 133 | + * Sets the {@link $ident}. |
|
| 134 | + * |
|
| 135 | + * @param string $ident |
|
| 136 | + */ |
|
| 137 | + public function setIdent($ident) { |
|
| 138 | + $this->ident = $ident; |
|
| 139 | + } |
|
| 140 | 140 | |
| 141 | - /** |
|
| 142 | - * Sets the {@link $priority}. |
|
| 143 | - * |
|
| 144 | - * @param string $priority |
|
| 145 | - */ |
|
| 146 | - public function setPriority($priority) { |
|
| 147 | - $this->priority = $priority; |
|
| 148 | - } |
|
| 141 | + /** |
|
| 142 | + * Sets the {@link $priority}. |
|
| 143 | + * |
|
| 144 | + * @param string $priority |
|
| 145 | + */ |
|
| 146 | + public function setPriority($priority) { |
|
| 147 | + $this->priority = $priority; |
|
| 148 | + } |
|
| 149 | 149 | |
| 150 | - /** |
|
| 151 | - * Sets the {@link $facility}. |
|
| 152 | - * |
|
| 153 | - * @param string $facility |
|
| 154 | - */ |
|
| 155 | - public function setFacility($facility) { |
|
| 156 | - $this->facility = $facility; |
|
| 157 | - } |
|
| 150 | + /** |
|
| 151 | + * Sets the {@link $facility}. |
|
| 152 | + * |
|
| 153 | + * @param string $facility |
|
| 154 | + */ |
|
| 155 | + public function setFacility($facility) { |
|
| 156 | + $this->facility = $facility; |
|
| 157 | + } |
|
| 158 | 158 | |
| 159 | - /** |
|
| 160 | - * Sets the {@link $overridePriority}. |
|
| 161 | - * |
|
| 162 | - * @param string $overridePriority |
|
| 163 | - */ |
|
| 164 | - public function setOverridePriority($overridePriority) { |
|
| 165 | - $this->overridePriority = $overridePriority; |
|
| 166 | - } |
|
| 159 | + /** |
|
| 160 | + * Sets the {@link $overridePriority}. |
|
| 161 | + * |
|
| 162 | + * @param string $overridePriority |
|
| 163 | + */ |
|
| 164 | + public function setOverridePriority($overridePriority) { |
|
| 165 | + $this->overridePriority = $overridePriority; |
|
| 166 | + } |
|
| 167 | 167 | |
| 168 | - /** |
|
| 169 | - * Sets the {@link $option}. |
|
| 170 | - * |
|
| 171 | - * @param string $option |
|
| 172 | - */ |
|
| 173 | - public function setOption($option) { |
|
| 174 | - $this->option = $option; |
|
| 175 | - } |
|
| 168 | + /** |
|
| 169 | + * Sets the {@link $option}. |
|
| 170 | + * |
|
| 171 | + * @param string $option |
|
| 172 | + */ |
|
| 173 | + public function setOption($option) { |
|
| 174 | + $this->option = $option; |
|
| 175 | + } |
|
| 176 | 176 | |
| 177 | - /** |
|
| 178 | - * Returns the {@link $ident}. |
|
| 179 | - * |
|
| 180 | - * @return string $ident |
|
| 181 | - */ |
|
| 182 | - public function getIdent() { |
|
| 183 | - return $this->ident; |
|
| 184 | - } |
|
| 177 | + /** |
|
| 178 | + * Returns the {@link $ident}. |
|
| 179 | + * |
|
| 180 | + * @return string $ident |
|
| 181 | + */ |
|
| 182 | + public function getIdent() { |
|
| 183 | + return $this->ident; |
|
| 184 | + } |
|
| 185 | 185 | |
| 186 | - /** |
|
| 187 | - * Returns the {@link $priority}. |
|
| 188 | - * |
|
| 189 | - * @return string |
|
| 190 | - */ |
|
| 191 | - public function getPriority() { |
|
| 192 | - return $this->priority; |
|
| 193 | - } |
|
| 186 | + /** |
|
| 187 | + * Returns the {@link $priority}. |
|
| 188 | + * |
|
| 189 | + * @return string |
|
| 190 | + */ |
|
| 191 | + public function getPriority() { |
|
| 192 | + return $this->priority; |
|
| 193 | + } |
|
| 194 | 194 | |
| 195 | - /** |
|
| 196 | - * Returns the {@link $facility}. |
|
| 197 | - * |
|
| 198 | - * @return string |
|
| 199 | - */ |
|
| 200 | - public function getFacility() { |
|
| 201 | - return $this->facility; |
|
| 202 | - } |
|
| 195 | + /** |
|
| 196 | + * Returns the {@link $facility}. |
|
| 197 | + * |
|
| 198 | + * @return string |
|
| 199 | + */ |
|
| 200 | + public function getFacility() { |
|
| 201 | + return $this->facility; |
|
| 202 | + } |
|
| 203 | 203 | |
| 204 | - /** |
|
| 205 | - * Returns the {@link $overridePriority}. |
|
| 206 | - * |
|
| 207 | - * @return string |
|
| 208 | - */ |
|
| 209 | - public function getOverridePriority() { |
|
| 210 | - return $this->overridePriority; |
|
| 211 | - } |
|
| 204 | + /** |
|
| 205 | + * Returns the {@link $overridePriority}. |
|
| 206 | + * |
|
| 207 | + * @return string |
|
| 208 | + */ |
|
| 209 | + public function getOverridePriority() { |
|
| 210 | + return $this->overridePriority; |
|
| 211 | + } |
|
| 212 | 212 | |
| 213 | - /** |
|
| 214 | - * Returns the {@link $option}. |
|
| 215 | - * |
|
| 216 | - * @return string |
|
| 217 | - */ |
|
| 218 | - public function getOption() { |
|
| 219 | - return $this->option; |
|
| 220 | - } |
|
| 213 | + /** |
|
| 214 | + * Returns the {@link $option}. |
|
| 215 | + * |
|
| 216 | + * @return string |
|
| 217 | + */ |
|
| 218 | + public function getOption() { |
|
| 219 | + return $this->option; |
|
| 220 | + } |
|
| 221 | 221 | |
| 222 | 222 | |
| 223 | - public function activateOptions() { |
|
| 224 | - $this->intPriority = $this->parsePriority(); |
|
| 225 | - $this->intOption = $this->parseOption(); |
|
| 226 | - $this->intFacility = $this->parseFacility(); |
|
| 223 | + public function activateOptions() { |
|
| 224 | + $this->intPriority = $this->parsePriority(); |
|
| 225 | + $this->intOption = $this->parseOption(); |
|
| 226 | + $this->intFacility = $this->parseFacility(); |
|
| 227 | 227 | |
| 228 | - $this->closed = false; |
|
| 229 | - } |
|
| 228 | + $this->closed = false; |
|
| 229 | + } |
|
| 230 | 230 | |
| 231 | - public function close() { |
|
| 232 | - if($this->closed != true) { |
|
| 233 | - closelog(); |
|
| 234 | - $this->closed = true; |
|
| 235 | - } |
|
| 236 | - } |
|
| 231 | + public function close() { |
|
| 232 | + if($this->closed != true) { |
|
| 233 | + closelog(); |
|
| 234 | + $this->closed = true; |
|
| 235 | + } |
|
| 236 | + } |
|
| 237 | 237 | |
| 238 | - /** |
|
| 239 | - * Appends the event to syslog. |
|
| 240 | - * |
|
| 241 | - * Log is opened and closed each time because if it is not closed, it |
|
| 242 | - * can cause the Apache httpd server to log to whatever ident/facility |
|
| 243 | - * was used in openlog(). |
|
| 244 | - * |
|
| 245 | - * @see http://www.php.net/manual/en/function.syslog.php#97843 |
|
| 246 | - */ |
|
| 247 | - public function append(Payone_Log4php_LoggerLoggingEvent $event) { |
|
| 248 | - $priority = $this->getSyslogPriority($event->getLevel()); |
|
| 249 | - $message = $this->layout->format($event); |
|
| 238 | + /** |
|
| 239 | + * Appends the event to syslog. |
|
| 240 | + * |
|
| 241 | + * Log is opened and closed each time because if it is not closed, it |
|
| 242 | + * can cause the Apache httpd server to log to whatever ident/facility |
|
| 243 | + * was used in openlog(). |
|
| 244 | + * |
|
| 245 | + * @see http://www.php.net/manual/en/function.syslog.php#97843 |
|
| 246 | + */ |
|
| 247 | + public function append(Payone_Log4php_LoggerLoggingEvent $event) { |
|
| 248 | + $priority = $this->getSyslogPriority($event->getLevel()); |
|
| 249 | + $message = $this->layout->format($event); |
|
| 250 | 250 | |
| 251 | - openlog($this->ident, $this->intOption, $this->intFacility); |
|
| 252 | - syslog($priority, $message); |
|
| 253 | - closelog(); |
|
| 254 | - } |
|
| 251 | + openlog($this->ident, $this->intOption, $this->intFacility); |
|
| 252 | + syslog($priority, $message); |
|
| 253 | + closelog(); |
|
| 254 | + } |
|
| 255 | 255 | |
| 256 | - /** Determines which syslog priority to use based on the given level. */ |
|
| 257 | - private function getSyslogPriority(Payone_Log4php_LoggerLevel $level) { |
|
| 258 | - if($this->overridePriority) { |
|
| 259 | - return $this->intPriority; |
|
| 260 | - } |
|
| 261 | - return $level->getSyslogEquivalent(); |
|
| 262 | - } |
|
| 256 | + /** Determines which syslog priority to use based on the given level. */ |
|
| 257 | + private function getSyslogPriority(Payone_Log4php_LoggerLevel $level) { |
|
| 258 | + if($this->overridePriority) { |
|
| 259 | + return $this->intPriority; |
|
| 260 | + } |
|
| 261 | + return $level->getSyslogEquivalent(); |
|
| 262 | + } |
|
| 263 | 263 | |
| 264 | - /** Parses a syslog option string and returns the correspodning int value. */ |
|
| 265 | - private function parseOption() { |
|
| 266 | - $value = 0; |
|
| 267 | - $options = explode('|', $this->option); |
|
| 264 | + /** Parses a syslog option string and returns the correspodning int value. */ |
|
| 265 | + private function parseOption() { |
|
| 266 | + $value = 0; |
|
| 267 | + $options = explode('|', $this->option); |
|
| 268 | 268 | |
| 269 | - foreach($options as $option) { |
|
| 270 | - if (!empty($option)) { |
|
| 271 | - $constant = "LOG_" . trim($option); |
|
| 272 | - if (defined($constant)) { |
|
| 273 | - $value |= constant($constant); |
|
| 274 | - } else { |
|
| 275 | - trigger_error("log4php: Invalid syslog option provided: $option. Whole option string: {$this->option}.", E_USER_WARNING); |
|
| 276 | - } |
|
| 277 | - } |
|
| 278 | - } |
|
| 279 | - return $value; |
|
| 280 | - } |
|
| 269 | + foreach($options as $option) { |
|
| 270 | + if (!empty($option)) { |
|
| 271 | + $constant = "LOG_" . trim($option); |
|
| 272 | + if (defined($constant)) { |
|
| 273 | + $value |= constant($constant); |
|
| 274 | + } else { |
|
| 275 | + trigger_error("log4php: Invalid syslog option provided: $option. Whole option string: {$this->option}.", E_USER_WARNING); |
|
| 276 | + } |
|
| 277 | + } |
|
| 278 | + } |
|
| 279 | + return $value; |
|
| 280 | + } |
|
| 281 | 281 | |
| 282 | - /** Parses the facility string and returns the corresponding int value. */ |
|
| 283 | - private function parseFacility() { |
|
| 284 | - if (!empty($this->facility)) { |
|
| 285 | - $constant = "LOG_" . trim($this->facility); |
|
| 286 | - if (defined($constant)) { |
|
| 287 | - return constant($constant); |
|
| 288 | - } else { |
|
| 289 | - trigger_error("log4php: Invalid syslog facility provided: {$this->facility}.", E_USER_WARNING); |
|
| 290 | - } |
|
| 291 | - } |
|
| 292 | - } |
|
| 282 | + /** Parses the facility string and returns the corresponding int value. */ |
|
| 283 | + private function parseFacility() { |
|
| 284 | + if (!empty($this->facility)) { |
|
| 285 | + $constant = "LOG_" . trim($this->facility); |
|
| 286 | + if (defined($constant)) { |
|
| 287 | + return constant($constant); |
|
| 288 | + } else { |
|
| 289 | + trigger_error("log4php: Invalid syslog facility provided: {$this->facility}.", E_USER_WARNING); |
|
| 290 | + } |
|
| 291 | + } |
|
| 292 | + } |
|
| 293 | 293 | |
| 294 | - /** Parses the priority string and returns the corresponding int value. */ |
|
| 295 | - private function parsePriority() { |
|
| 296 | - if (!empty($this->priority)) { |
|
| 297 | - $constant = "LOG_" . trim($this->priority); |
|
| 298 | - if (defined($constant)) { |
|
| 299 | - return constant($constant); |
|
| 300 | - } else { |
|
| 301 | - trigger_error("log4php: Invalid syslog priority provided: {$this->priority}.", E_USER_WARNING); |
|
| 302 | - } |
|
| 303 | - } |
|
| 304 | - } |
|
| 294 | + /** Parses the priority string and returns the corresponding int value. */ |
|
| 295 | + private function parsePriority() { |
|
| 296 | + if (!empty($this->priority)) { |
|
| 297 | + $constant = "LOG_" . trim($this->priority); |
|
| 298 | + if (defined($constant)) { |
|
| 299 | + return constant($constant); |
|
| 300 | + } else { |
|
| 301 | + trigger_error("log4php: Invalid syslog priority provided: {$this->priority}.", E_USER_WARNING); |
|
| 302 | + } |
|
| 303 | + } |
|
| 304 | + } |
|
| 305 | 305 | } |
@@ -229,7 +229,7 @@ discard block |
||
| 229 | 229 | } |
| 230 | 230 | |
| 231 | 231 | public function close() { |
| 232 | - if($this->closed != true) { |
|
| 232 | + if ($this->closed != true) { |
|
| 233 | 233 | closelog(); |
| 234 | 234 | $this->closed = true; |
| 235 | 235 | } |
@@ -255,7 +255,7 @@ discard block |
||
| 255 | 255 | |
| 256 | 256 | /** Determines which syslog priority to use based on the given level. */ |
| 257 | 257 | private function getSyslogPriority(Payone_Log4php_LoggerLevel $level) { |
| 258 | - if($this->overridePriority) { |
|
| 258 | + if ($this->overridePriority) { |
|
| 259 | 259 | return $this->intPriority; |
| 260 | 260 | } |
| 261 | 261 | return $level->getSyslogEquivalent(); |
@@ -266,7 +266,7 @@ discard block |
||
| 266 | 266 | $value = 0; |
| 267 | 267 | $options = explode('|', $this->option); |
| 268 | 268 | |
| 269 | - foreach($options as $option) { |
|
| 269 | + foreach ($options as $option) { |
|
| 270 | 270 | if (!empty($option)) { |
| 271 | 271 | $constant = "LOG_" . trim($option); |
| 272 | 272 | if (defined($constant)) { |
@@ -19,7 +19,7 @@ discard block |
||
| 19 | 19 | */ |
| 20 | 20 | |
| 21 | 21 | if (function_exists('__autoload')) { |
| 22 | - //trigger_error("log4php: It looks like your code is using an __autoload() function. log4php uses spl_autoload_register() which will bypass your __autoload() function and may break autoloading.", E_USER_WARNING); |
|
| 22 | + //trigger_error("log4php: It looks like your code is using an __autoload() function. log4php uses spl_autoload_register() which will bypass your __autoload() function and may break autoloading.", E_USER_WARNING); |
|
| 23 | 23 | } |
| 24 | 24 | |
| 25 | 25 | spl_autoload_register(array('Payone_Log4php_LoggerAutoloader', 'autoload')); |
@@ -33,108 +33,108 @@ discard block |
||
| 33 | 33 | */ |
| 34 | 34 | class Payone_Log4php_LoggerAutoloader { |
| 35 | 35 | |
| 36 | - /** Maps classnames to files containing the class. */ |
|
| 37 | - private static $classes = array( |
|
| 36 | + /** Maps classnames to files containing the class. */ |
|
| 37 | + private static $classes = array( |
|
| 38 | 38 | |
| 39 | - // Base |
|
| 40 | - 'Payone_Log4php_LoggerAppender' => '/LoggerAppender.php', |
|
| 41 | - 'Payone_Log4php_LoggerAppenderPool' => '/LoggerAppenderPool.php', |
|
| 42 | - 'Payone_Log4php_LoggerConfigurable' => '/LoggerConfigurable.php', |
|
| 43 | - 'Payone_Log4php_LoggerConfigurator' => '/LoggerConfigurator.php', |
|
| 44 | - 'Payone_Log4php_LoggerException' => '/LoggerException.php', |
|
| 45 | - 'Payone_Log4php_LoggerFilter' => '/LoggerFilter.php', |
|
| 46 | - 'Payone_Log4php_LoggerHierarchy' => '/LoggerHierarchy.php', |
|
| 47 | - 'Payone_Log4php_LoggerLevel' => '/LoggerLevel.php', |
|
| 48 | - 'Payone_Log4php_LoggerLocationInfo' => '/LoggerLocationInfo.php', |
|
| 49 | - 'Payone_Log4php_LoggerLoggingEvent' => '/LoggerLoggingEvent.php', |
|
| 50 | - 'Payone_Log4php_LoggerMDC' => '/LoggerMDC.php', |
|
| 51 | - 'Payone_Log4php_LoggerNDC' => '/LoggerNDC.php', |
|
| 52 | - 'Payone_Log4php_LoggerLayout' => '/LoggerLayout.php', |
|
| 53 | - 'Payone_Log4php_LoggerReflectionUtils' => '/LoggerReflectionUtils.php', |
|
| 54 | - 'Payone_Log4php_LoggerRoot' => '/LoggerRoot.php', |
|
| 55 | - 'Payone_Log4php_LoggerThrowableInformation' => '/LoggerThrowableInformation.php', |
|
| 39 | + // Base |
|
| 40 | + 'Payone_Log4php_LoggerAppender' => '/LoggerAppender.php', |
|
| 41 | + 'Payone_Log4php_LoggerAppenderPool' => '/LoggerAppenderPool.php', |
|
| 42 | + 'Payone_Log4php_LoggerConfigurable' => '/LoggerConfigurable.php', |
|
| 43 | + 'Payone_Log4php_LoggerConfigurator' => '/LoggerConfigurator.php', |
|
| 44 | + 'Payone_Log4php_LoggerException' => '/LoggerException.php', |
|
| 45 | + 'Payone_Log4php_LoggerFilter' => '/LoggerFilter.php', |
|
| 46 | + 'Payone_Log4php_LoggerHierarchy' => '/LoggerHierarchy.php', |
|
| 47 | + 'Payone_Log4php_LoggerLevel' => '/LoggerLevel.php', |
|
| 48 | + 'Payone_Log4php_LoggerLocationInfo' => '/LoggerLocationInfo.php', |
|
| 49 | + 'Payone_Log4php_LoggerLoggingEvent' => '/LoggerLoggingEvent.php', |
|
| 50 | + 'Payone_Log4php_LoggerMDC' => '/LoggerMDC.php', |
|
| 51 | + 'Payone_Log4php_LoggerNDC' => '/LoggerNDC.php', |
|
| 52 | + 'Payone_Log4php_LoggerLayout' => '/LoggerLayout.php', |
|
| 53 | + 'Payone_Log4php_LoggerReflectionUtils' => '/LoggerReflectionUtils.php', |
|
| 54 | + 'Payone_Log4php_LoggerRoot' => '/LoggerRoot.php', |
|
| 55 | + 'Payone_Log4php_LoggerThrowableInformation' => '/LoggerThrowableInformation.php', |
|
| 56 | 56 | |
| 57 | - // Appenders |
|
| 58 | - 'Payone_Log4php_LoggerAppenderConsole' => '/LoggerAppenderConsole.php', |
|
| 59 | - 'Payone_Log4php_LoggerAppenderDailyFile' => '/LoggerAppenderDailyFile.php', |
|
| 60 | - 'Payone_Log4php_LoggerAppenderEcho' => '/LoggerAppenderEcho.php', |
|
| 61 | - 'Payone_Log4php_LoggerAppenderFile' => '/LoggerAppenderFile.php', |
|
| 62 | - 'Payone_Log4php_LoggerAppenderMail' => '/LoggerAppenderMail.php', |
|
| 63 | - 'Payone_Log4php_LoggerAppenderMailEvent' => '/LoggerAppenderMailEvent.php', |
|
| 64 | - 'Payone_Log4php_LoggerAppenderMongoDB' => '/LoggerAppenderMongoDB.php', |
|
| 65 | - 'Payone_Log4php_LoggerAppenderNull' => '/LoggerAppenderNull.php', |
|
| 66 | - 'Payone_Log4php_LoggerAppenderPDO' => '/LoggerAppenderPDO.php', |
|
| 67 | - 'Payone_Log4php_LoggerAppenderPhp' => '/LoggerAppenderPhp.php', |
|
| 68 | - 'Payone_Log4php_LoggerAppenderRollingFile' => '/LoggerAppenderRollingFile.php', |
|
| 69 | - 'Payone_Log4php_LoggerAppenderSocket' => '/LoggerAppenderSocket.php', |
|
| 70 | - 'Payone_Log4php_LoggerAppenderSyslog' => '/LoggerAppenderSyslog.php', |
|
| 57 | + // Appenders |
|
| 58 | + 'Payone_Log4php_LoggerAppenderConsole' => '/LoggerAppenderConsole.php', |
|
| 59 | + 'Payone_Log4php_LoggerAppenderDailyFile' => '/LoggerAppenderDailyFile.php', |
|
| 60 | + 'Payone_Log4php_LoggerAppenderEcho' => '/LoggerAppenderEcho.php', |
|
| 61 | + 'Payone_Log4php_LoggerAppenderFile' => '/LoggerAppenderFile.php', |
|
| 62 | + 'Payone_Log4php_LoggerAppenderMail' => '/LoggerAppenderMail.php', |
|
| 63 | + 'Payone_Log4php_LoggerAppenderMailEvent' => '/LoggerAppenderMailEvent.php', |
|
| 64 | + 'Payone_Log4php_LoggerAppenderMongoDB' => '/LoggerAppenderMongoDB.php', |
|
| 65 | + 'Payone_Log4php_LoggerAppenderNull' => '/LoggerAppenderNull.php', |
|
| 66 | + 'Payone_Log4php_LoggerAppenderPDO' => '/LoggerAppenderPDO.php', |
|
| 67 | + 'Payone_Log4php_LoggerAppenderPhp' => '/LoggerAppenderPhp.php', |
|
| 68 | + 'Payone_Log4php_LoggerAppenderRollingFile' => '/LoggerAppenderRollingFile.php', |
|
| 69 | + 'Payone_Log4php_LoggerAppenderSocket' => '/LoggerAppenderSocket.php', |
|
| 70 | + 'Payone_Log4php_LoggerAppenderSyslog' => '/LoggerAppenderSyslog.php', |
|
| 71 | 71 | |
| 72 | - // Configurators |
|
| 73 | - 'Payone_Log4php_LoggerConfigurationAdapter' => '/LoggerConfigurationAdapter.php', |
|
| 74 | - 'Payone_Log4php_LoggerConfigurationAdapterINI' => '/LoggerConfigurationAdapterINI.php', |
|
| 75 | - 'Payone_Log4php_LoggerConfigurationAdapterPHP' => '/LoggerConfigurationAdapterPHP.php', |
|
| 76 | - 'Payone_Log4php_LoggerConfigurationAdapterXML' => '/LoggerConfigurationAdapterXML.php', |
|
| 77 | - 'Payone_Log4php_LoggerConfiguratorDefault' => '/LoggerConfiguratorDefault.php', |
|
| 72 | + // Configurators |
|
| 73 | + 'Payone_Log4php_LoggerConfigurationAdapter' => '/LoggerConfigurationAdapter.php', |
|
| 74 | + 'Payone_Log4php_LoggerConfigurationAdapterINI' => '/LoggerConfigurationAdapterINI.php', |
|
| 75 | + 'Payone_Log4php_LoggerConfigurationAdapterPHP' => '/LoggerConfigurationAdapterPHP.php', |
|
| 76 | + 'Payone_Log4php_LoggerConfigurationAdapterXML' => '/LoggerConfigurationAdapterXML.php', |
|
| 77 | + 'Payone_Log4php_LoggerConfiguratorDefault' => '/LoggerConfiguratorDefault.php', |
|
| 78 | 78 | |
| 79 | - // Filters |
|
| 80 | - 'Payone_Log4php_LoggerFilterDenyAll' => '/LoggerFilterDenyAll.php', |
|
| 81 | - 'Payone_Log4php_LoggerFilterLevelMatch' => '/LoggerFilterLevelMatch.php', |
|
| 82 | - 'Payone_Log4php_LoggerFilterLevelRange' => '/LoggerFilterLevelRange.php', |
|
| 83 | - 'Payone_Log4php_LoggerFilterStringMatch' => '/LoggerFilterStringMatch.php', |
|
| 79 | + // Filters |
|
| 80 | + 'Payone_Log4php_LoggerFilterDenyAll' => '/LoggerFilterDenyAll.php', |
|
| 81 | + 'Payone_Log4php_LoggerFilterLevelMatch' => '/LoggerFilterLevelMatch.php', |
|
| 82 | + 'Payone_Log4php_LoggerFilterLevelRange' => '/LoggerFilterLevelRange.php', |
|
| 83 | + 'Payone_Log4php_LoggerFilterStringMatch' => '/LoggerFilterStringMatch.php', |
|
| 84 | 84 | |
| 85 | - // Helpers |
|
| 86 | - 'Payone_Log4php_LoggerFormattingInfo' => '/LoggerFormattingInfo.php', |
|
| 87 | - 'Payone_Log4php_LoggerOptionConverter' => '/LoggerOptionConverter.php', |
|
| 88 | - 'Payone_Log4php_LoggerPatternParser' => '/LoggerPatternParser.php', |
|
| 89 | - 'Payone_Log4php_LoggerUtils' => '/LoggerUtils.php', |
|
| 85 | + // Helpers |
|
| 86 | + 'Payone_Log4php_LoggerFormattingInfo' => '/LoggerFormattingInfo.php', |
|
| 87 | + 'Payone_Log4php_LoggerOptionConverter' => '/LoggerOptionConverter.php', |
|
| 88 | + 'Payone_Log4php_LoggerPatternParser' => '/LoggerPatternParser.php', |
|
| 89 | + 'Payone_Log4php_LoggerUtils' => '/LoggerUtils.php', |
|
| 90 | 90 | |
| 91 | - // Pattern converters |
|
| 92 | - 'Payone_Log4php_LoggerPatternConverter' => '/LoggerPatternConverter.php', |
|
| 93 | - 'Payone_Log4php_LoggerPatternConverterClass' => '/LoggerPatternConverterClass.php', |
|
| 94 | - 'Payone_Log4php_LoggerPatternConverterCookie' => '/LoggerPatternConverterCookie.php', |
|
| 95 | - 'Payone_Log4php_LoggerPatternConverterDate' => '/LoggerPatternConverterDate.php', |
|
| 96 | - 'Payone_Log4php_LoggerPatternConverterEnvironment' => '/LoggerPatternConverterEnvironment.php', |
|
| 97 | - 'Payone_Log4php_LoggerPatternConverterFile' => '/LoggerPatternConverterFile.php', |
|
| 98 | - 'Payone_Log4php_LoggerPatternConverterLevel' => '/LoggerPatternConverterLevel.php', |
|
| 99 | - 'Payone_Log4php_LoggerPatternConverterLine' => '/LoggerPatternConverterLine.php', |
|
| 100 | - 'Payone_Log4php_LoggerPatternConverterLiteral' => '/LoggerPatternConverterLiteral.php', |
|
| 101 | - 'Payone_Log4php_LoggerPatternConverterLogger' => '/LoggerPatternConverterLogger.php', |
|
| 102 | - 'Payone_Log4php_LoggerPatternConverterMDC' => '/LoggerPatternConverterMDC.php', |
|
| 103 | - 'Payone_Log4php_LoggerPatternConverterMessage' => '/LoggerPatternConverterMessage.php', |
|
| 104 | - 'Payone_Log4php_LoggerPatternConverterMethod' => '/LoggerPatternConverterMethod.php', |
|
| 105 | - 'Payone_Log4php_LoggerPatternConverterNDC' => '/LoggerPatternConverterNDC.php', |
|
| 106 | - 'Payone_Log4php_LoggerPatternConverterNewLine' => '/LoggerPatternConverterNewLine.php', |
|
| 107 | - 'Payone_Log4php_LoggerPatternConverterProcess' => '/LoggerPatternConverterProcess.php', |
|
| 108 | - 'Payone_Log4php_LoggerPatternConverterRelative' => '/LoggerPatternConverterRelative.php', |
|
| 109 | - 'Payone_Log4php_LoggerPatternConverterRequest' => '/LoggerPatternConverterRequest.php', |
|
| 110 | - 'Payone_Log4php_LoggerPatternConverterServer' => '/LoggerPatternConverterServer.php', |
|
| 111 | - 'Payone_Log4php_LoggerPatternConverterSession' => '/LoggerPatternConverterSession.php', |
|
| 112 | - 'Payone_Log4php_LoggerPatternConverterSessionID' => '/LoggerPatternConverterSessionID.php', |
|
| 113 | - 'Payone_Log4php_LoggerPatternConverterSuperglobal' => '/LoggerPatternConverterSuperglobal.php', |
|
| 114 | - 'Payone_Log4php_LoggerPatternConverterThrowable' => '/LoggerPatternConverterThrowable.php', |
|
| 91 | + // Pattern converters |
|
| 92 | + 'Payone_Log4php_LoggerPatternConverter' => '/LoggerPatternConverter.php', |
|
| 93 | + 'Payone_Log4php_LoggerPatternConverterClass' => '/LoggerPatternConverterClass.php', |
|
| 94 | + 'Payone_Log4php_LoggerPatternConverterCookie' => '/LoggerPatternConverterCookie.php', |
|
| 95 | + 'Payone_Log4php_LoggerPatternConverterDate' => '/LoggerPatternConverterDate.php', |
|
| 96 | + 'Payone_Log4php_LoggerPatternConverterEnvironment' => '/LoggerPatternConverterEnvironment.php', |
|
| 97 | + 'Payone_Log4php_LoggerPatternConverterFile' => '/LoggerPatternConverterFile.php', |
|
| 98 | + 'Payone_Log4php_LoggerPatternConverterLevel' => '/LoggerPatternConverterLevel.php', |
|
| 99 | + 'Payone_Log4php_LoggerPatternConverterLine' => '/LoggerPatternConverterLine.php', |
|
| 100 | + 'Payone_Log4php_LoggerPatternConverterLiteral' => '/LoggerPatternConverterLiteral.php', |
|
| 101 | + 'Payone_Log4php_LoggerPatternConverterLogger' => '/LoggerPatternConverterLogger.php', |
|
| 102 | + 'Payone_Log4php_LoggerPatternConverterMDC' => '/LoggerPatternConverterMDC.php', |
|
| 103 | + 'Payone_Log4php_LoggerPatternConverterMessage' => '/LoggerPatternConverterMessage.php', |
|
| 104 | + 'Payone_Log4php_LoggerPatternConverterMethod' => '/LoggerPatternConverterMethod.php', |
|
| 105 | + 'Payone_Log4php_LoggerPatternConverterNDC' => '/LoggerPatternConverterNDC.php', |
|
| 106 | + 'Payone_Log4php_LoggerPatternConverterNewLine' => '/LoggerPatternConverterNewLine.php', |
|
| 107 | + 'Payone_Log4php_LoggerPatternConverterProcess' => '/LoggerPatternConverterProcess.php', |
|
| 108 | + 'Payone_Log4php_LoggerPatternConverterRelative' => '/LoggerPatternConverterRelative.php', |
|
| 109 | + 'Payone_Log4php_LoggerPatternConverterRequest' => '/LoggerPatternConverterRequest.php', |
|
| 110 | + 'Payone_Log4php_LoggerPatternConverterServer' => '/LoggerPatternConverterServer.php', |
|
| 111 | + 'Payone_Log4php_LoggerPatternConverterSession' => '/LoggerPatternConverterSession.php', |
|
| 112 | + 'Payone_Log4php_LoggerPatternConverterSessionID' => '/LoggerPatternConverterSessionID.php', |
|
| 113 | + 'Payone_Log4php_LoggerPatternConverterSuperglobal' => '/LoggerPatternConverterSuperglobal.php', |
|
| 114 | + 'Payone_Log4php_LoggerPatternConverterThrowable' => '/LoggerPatternConverterThrowable.php', |
|
| 115 | 115 | |
| 116 | - // Layouts |
|
| 117 | - 'Payone_Log4php_LoggerLayoutHtml' => '/LoggerLayoutHtml.php', |
|
| 118 | - 'Payone_Log4php_LoggerLayoutPattern' => '/LoggerLayoutPattern.php', |
|
| 119 | - 'Payone_Log4php_LoggerLayoutSerialized' => '/LoggerLayoutSerialized.php', |
|
| 120 | - 'Payone_Log4php_LoggerLayoutSimple' => '/LoggerLayoutSimple.php', |
|
| 121 | - 'Payone_Log4php_LoggerLayoutTTCC' => '/LoggerLayoutTTCC.php', |
|
| 122 | - 'Payone_Log4php_LoggerLayoutXml' => '/LoggerLayoutXml.php', |
|
| 116 | + // Layouts |
|
| 117 | + 'Payone_Log4php_LoggerLayoutHtml' => '/LoggerLayoutHtml.php', |
|
| 118 | + 'Payone_Log4php_LoggerLayoutPattern' => '/LoggerLayoutPattern.php', |
|
| 119 | + 'Payone_Log4php_LoggerLayoutSerialized' => '/LoggerLayoutSerialized.php', |
|
| 120 | + 'Payone_Log4php_LoggerLayoutSimple' => '/LoggerLayoutSimple.php', |
|
| 121 | + 'Payone_Log4php_LoggerLayoutTTCC' => '/LoggerLayoutTTCC.php', |
|
| 122 | + 'Payone_Log4php_LoggerLayoutXml' => '/LoggerLayoutXml.php', |
|
| 123 | 123 | |
| 124 | - // Renderers |
|
| 125 | - 'Payone_Log4php_LoggerRendererDefault' => '/LoggerRendererDefault.php', |
|
| 126 | - 'Payone_Log4php_LoggerRendererException' => '/LoggerRendererException.php', |
|
| 127 | - 'Payone_Log4php_LoggerRendererMap' => '/LoggerRendererMap.php', |
|
| 128 | - 'Payone_Log4php_LoggerRendererObject' => '/LoggerRendererObject.php', |
|
| 129 | - ); |
|
| 124 | + // Renderers |
|
| 125 | + 'Payone_Log4php_LoggerRendererDefault' => '/LoggerRendererDefault.php', |
|
| 126 | + 'Payone_Log4php_LoggerRendererException' => '/LoggerRendererException.php', |
|
| 127 | + 'Payone_Log4php_LoggerRendererMap' => '/LoggerRendererMap.php', |
|
| 128 | + 'Payone_Log4php_LoggerRendererObject' => '/LoggerRendererObject.php', |
|
| 129 | + ); |
|
| 130 | 130 | |
| 131 | - /** |
|
| 132 | - * Loads a class. |
|
| 133 | - * @param string $className The name of the class to load. |
|
| 134 | - */ |
|
| 135 | - public static function autoload($className) { |
|
| 136 | - if(isset(self::$classes[$className])) { |
|
| 137 | - require_once dirname(__FILE__) . self::$classes[$className]; |
|
| 138 | - } |
|
| 139 | - } |
|
| 131 | + /** |
|
| 132 | + * Loads a class. |
|
| 133 | + * @param string $className The name of the class to load. |
|
| 134 | + */ |
|
| 135 | + public static function autoload($className) { |
|
| 136 | + if(isset(self::$classes[$className])) { |
|
| 137 | + require_once dirname(__FILE__) . self::$classes[$className]; |
|
| 138 | + } |
|
| 139 | + } |
|
| 140 | 140 | } |
@@ -133,7 +133,7 @@ |
||
| 133 | 133 | * @param string $className The name of the class to load. |
| 134 | 134 | */ |
| 135 | 135 | public static function autoload($className) { |
| 136 | - if(isset(self::$classes[$className])) { |
|
| 136 | + if (isset(self::$classes[$className])) { |
|
| 137 | 137 | require_once dirname(__FILE__) . self::$classes[$className]; |
| 138 | 138 | } |
| 139 | 139 | } |
@@ -54,157 +54,157 @@ |
||
| 54 | 54 | * @subpackage layouts |
| 55 | 55 | */ |
| 56 | 56 | class Payone_Log4php_LoggerLayoutXml extends Payone_Log4php_LoggerLayout { |
| 57 | - const LOG4J_NS_PREFIX ='log4j'; |
|
| 58 | - const LOG4J_NS = 'http://jakarta.apache.org/log4j/'; |
|
| 57 | + const LOG4J_NS_PREFIX ='log4j'; |
|
| 58 | + const LOG4J_NS = 'http://jakarta.apache.org/log4j/'; |
|
| 59 | 59 | |
| 60 | - const LOG4PHP_NS_PREFIX = 'log4php'; |
|
| 61 | - const LOG4PHP_NS = 'http://logging.apache.org/log4php/'; |
|
| 60 | + const LOG4PHP_NS_PREFIX = 'log4php'; |
|
| 61 | + const LOG4PHP_NS = 'http://logging.apache.org/log4php/'; |
|
| 62 | 62 | |
| 63 | - const CDATA_START = '<![CDATA['; |
|
| 64 | - const CDATA_END = ']]>'; |
|
| 65 | - const CDATA_PSEUDO_END = ']]>'; |
|
| 66 | - const CDATA_EMBEDDED_END = ']]>]]><![CDATA['; |
|
| 63 | + const CDATA_START = '<![CDATA['; |
|
| 64 | + const CDATA_END = ']]>'; |
|
| 65 | + const CDATA_PSEUDO_END = ']]>'; |
|
| 66 | + const CDATA_EMBEDDED_END = ']]>]]><![CDATA['; |
|
| 67 | 67 | |
| 68 | - /** |
|
| 69 | - * If set to true then the file name and line number of the origin of the |
|
| 70 | - * log statement will be output. |
|
| 71 | - * @var boolean |
|
| 72 | - */ |
|
| 73 | - protected $locationInfo = true; |
|
| 68 | + /** |
|
| 69 | + * If set to true then the file name and line number of the origin of the |
|
| 70 | + * log statement will be output. |
|
| 71 | + * @var boolean |
|
| 72 | + */ |
|
| 73 | + protected $locationInfo = true; |
|
| 74 | 74 | |
| 75 | - /** |
|
| 76 | - * If set to true, log4j namespace will be used instead of the log4php |
|
| 77 | - * namespace. |
|
| 78 | - * @var boolean |
|
| 79 | - */ |
|
| 80 | - protected $log4jNamespace = false; |
|
| 75 | + /** |
|
| 76 | + * If set to true, log4j namespace will be used instead of the log4php |
|
| 77 | + * namespace. |
|
| 78 | + * @var boolean |
|
| 79 | + */ |
|
| 80 | + protected $log4jNamespace = false; |
|
| 81 | 81 | |
| 82 | - /** The namespace in use. */ |
|
| 83 | - protected $namespace = self::LOG4PHP_NS; |
|
| 82 | + /** The namespace in use. */ |
|
| 83 | + protected $namespace = self::LOG4PHP_NS; |
|
| 84 | 84 | |
| 85 | - /** The namespace prefix in use */ |
|
| 86 | - protected $namespacePrefix = self::LOG4PHP_NS_PREFIX; |
|
| 85 | + /** The namespace prefix in use */ |
|
| 86 | + protected $namespacePrefix = self::LOG4PHP_NS_PREFIX; |
|
| 87 | 87 | |
| 88 | - public function activateOptions() { |
|
| 89 | - if ($this->getLog4jNamespace()) { |
|
| 90 | - $this->namespace = self::LOG4J_NS; |
|
| 91 | - $this->namespacePrefix = self::LOG4J_NS_PREFIX; |
|
| 92 | - } else { |
|
| 93 | - $this->namespace = self::LOG4PHP_NS; |
|
| 94 | - $this->namespacePrefix = self::LOG4PHP_NS_PREFIX; |
|
| 95 | - } |
|
| 96 | - } |
|
| 88 | + public function activateOptions() { |
|
| 89 | + if ($this->getLog4jNamespace()) { |
|
| 90 | + $this->namespace = self::LOG4J_NS; |
|
| 91 | + $this->namespacePrefix = self::LOG4J_NS_PREFIX; |
|
| 92 | + } else { |
|
| 93 | + $this->namespace = self::LOG4PHP_NS; |
|
| 94 | + $this->namespacePrefix = self::LOG4PHP_NS_PREFIX; |
|
| 95 | + } |
|
| 96 | + } |
|
| 97 | 97 | |
| 98 | - /** |
|
| 99 | - * @return string |
|
| 100 | - */ |
|
| 101 | - public function getHeader() { |
|
| 102 | - return "<{$this->namespacePrefix}:eventSet ". |
|
| 103 | - "xmlns:{$this->namespacePrefix}=\"{$this->namespace}\" ". |
|
| 104 | - "version=\"0.3\" ". |
|
| 105 | - "includesLocationInfo=\"".($this->getLocationInfo() ? "true" : "false")."\"". |
|
| 106 | - ">" . PHP_EOL; |
|
| 107 | - } |
|
| 98 | + /** |
|
| 99 | + * @return string |
|
| 100 | + */ |
|
| 101 | + public function getHeader() { |
|
| 102 | + return "<{$this->namespacePrefix}:eventSet ". |
|
| 103 | + "xmlns:{$this->namespacePrefix}=\"{$this->namespace}\" ". |
|
| 104 | + "version=\"0.3\" ". |
|
| 105 | + "includesLocationInfo=\"".($this->getLocationInfo() ? "true" : "false")."\"". |
|
| 106 | + ">" . PHP_EOL; |
|
| 107 | + } |
|
| 108 | 108 | |
| 109 | - /** |
|
| 110 | - * Formats a {@link LoggerLoggingEvent} in conformance with the log4php.dtd. |
|
| 111 | - * |
|
| 112 | - * @param Payone_Log4php_LoggerLoggingEvent $event |
|
| 113 | - * @return string |
|
| 114 | - */ |
|
| 115 | - public function format(Payone_Log4php_LoggerLoggingEvent $event) { |
|
| 116 | - $ns = $this->namespacePrefix; |
|
| 109 | + /** |
|
| 110 | + * Formats a {@link LoggerLoggingEvent} in conformance with the log4php.dtd. |
|
| 111 | + * |
|
| 112 | + * @param Payone_Log4php_LoggerLoggingEvent $event |
|
| 113 | + * @return string |
|
| 114 | + */ |
|
| 115 | + public function format(Payone_Log4php_LoggerLoggingEvent $event) { |
|
| 116 | + $ns = $this->namespacePrefix; |
|
| 117 | 117 | |
| 118 | - $loggerName = $event->getLoggerName(); |
|
| 119 | - $timeStamp = number_format((float)($event->getTimeStamp() * 1000), 0, '', ''); |
|
| 120 | - $thread = $event->getThreadName(); |
|
| 121 | - $level = $event->getLevel()->toString(); |
|
| 118 | + $loggerName = $event->getLoggerName(); |
|
| 119 | + $timeStamp = number_format((float)($event->getTimeStamp() * 1000), 0, '', ''); |
|
| 120 | + $thread = $event->getThreadName(); |
|
| 121 | + $level = $event->getLevel()->toString(); |
|
| 122 | 122 | |
| 123 | - $buf = "<$ns:event logger=\"{$loggerName}\" level=\"{$level}\" thread=\"{$thread}\" timestamp=\"{$timeStamp}\">".PHP_EOL; |
|
| 124 | - $buf .= "<$ns:message>"; |
|
| 125 | - $buf .= $this->encodeCDATA($event->getRenderedMessage()); |
|
| 126 | - $buf .= "</$ns:message>".PHP_EOL; |
|
| 123 | + $buf = "<$ns:event logger=\"{$loggerName}\" level=\"{$level}\" thread=\"{$thread}\" timestamp=\"{$timeStamp}\">".PHP_EOL; |
|
| 124 | + $buf .= "<$ns:message>"; |
|
| 125 | + $buf .= $this->encodeCDATA($event->getRenderedMessage()); |
|
| 126 | + $buf .= "</$ns:message>".PHP_EOL; |
|
| 127 | 127 | |
| 128 | - $ndc = $event->getNDC(); |
|
| 129 | - if(!empty($ndc)) { |
|
| 130 | - $buf .= "<$ns:NDC><![CDATA["; |
|
| 131 | - $buf .= $this->encodeCDATA($ndc); |
|
| 132 | - $buf .= "]]></$ns:NDC>".PHP_EOL; |
|
| 133 | - } |
|
| 128 | + $ndc = $event->getNDC(); |
|
| 129 | + if(!empty($ndc)) { |
|
| 130 | + $buf .= "<$ns:NDC><![CDATA["; |
|
| 131 | + $buf .= $this->encodeCDATA($ndc); |
|
| 132 | + $buf .= "]]></$ns:NDC>".PHP_EOL; |
|
| 133 | + } |
|
| 134 | 134 | |
| 135 | - $mdcMap = $event->getMDCMap(); |
|
| 136 | - if (!empty($mdcMap)) { |
|
| 137 | - $buf .= "<$ns:properties>".PHP_EOL; |
|
| 138 | - foreach ($mdcMap as $name=>$value) { |
|
| 139 | - $buf .= "<$ns:data name=\"$name\" value=\"$value\" />".PHP_EOL; |
|
| 140 | - } |
|
| 141 | - $buf .= "</$ns:properties>".PHP_EOL; |
|
| 142 | - } |
|
| 135 | + $mdcMap = $event->getMDCMap(); |
|
| 136 | + if (!empty($mdcMap)) { |
|
| 137 | + $buf .= "<$ns:properties>".PHP_EOL; |
|
| 138 | + foreach ($mdcMap as $name=>$value) { |
|
| 139 | + $buf .= "<$ns:data name=\"$name\" value=\"$value\" />".PHP_EOL; |
|
| 140 | + } |
|
| 141 | + $buf .= "</$ns:properties>".PHP_EOL; |
|
| 142 | + } |
|
| 143 | 143 | |
| 144 | - if ($this->getLocationInfo()) { |
|
| 145 | - $locationInfo = $event->getLocationInformation(); |
|
| 146 | - $buf .= "<$ns:locationInfo ". |
|
| 147 | - "class=\"" . $locationInfo->getClassName() . "\" ". |
|
| 148 | - "file=\"" . htmlentities($locationInfo->getFileName(), ENT_QUOTES) . "\" ". |
|
| 149 | - "line=\"" . $locationInfo->getLineNumber() . "\" ". |
|
| 150 | - "method=\"" . $locationInfo->getMethodName() . "\" "; |
|
| 151 | - $buf .= "/>".PHP_EOL; |
|
| 152 | - } |
|
| 144 | + if ($this->getLocationInfo()) { |
|
| 145 | + $locationInfo = $event->getLocationInformation(); |
|
| 146 | + $buf .= "<$ns:locationInfo ". |
|
| 147 | + "class=\"" . $locationInfo->getClassName() . "\" ". |
|
| 148 | + "file=\"" . htmlentities($locationInfo->getFileName(), ENT_QUOTES) . "\" ". |
|
| 149 | + "line=\"" . $locationInfo->getLineNumber() . "\" ". |
|
| 150 | + "method=\"" . $locationInfo->getMethodName() . "\" "; |
|
| 151 | + $buf .= "/>".PHP_EOL; |
|
| 152 | + } |
|
| 153 | 153 | |
| 154 | - $buf .= "</$ns:event>".PHP_EOL; |
|
| 154 | + $buf .= "</$ns:event>".PHP_EOL; |
|
| 155 | 155 | |
| 156 | - return $buf; |
|
| 157 | - } |
|
| 156 | + return $buf; |
|
| 157 | + } |
|
| 158 | 158 | |
| 159 | - /** |
|
| 160 | - * @return string |
|
| 161 | - */ |
|
| 162 | - public function getFooter() { |
|
| 163 | - return "</{$this->namespacePrefix}:eventSet>" . PHP_EOL; |
|
| 164 | - } |
|
| 159 | + /** |
|
| 160 | + * @return string |
|
| 161 | + */ |
|
| 162 | + public function getFooter() { |
|
| 163 | + return "</{$this->namespacePrefix}:eventSet>" . PHP_EOL; |
|
| 164 | + } |
|
| 165 | 165 | |
| 166 | 166 | |
| 167 | - /** |
|
| 168 | - * Whether or not file name and line number will be included in the output. |
|
| 169 | - * @return boolean |
|
| 170 | - */ |
|
| 171 | - public function getLocationInfo() { |
|
| 172 | - return $this->locationInfo; |
|
| 173 | - } |
|
| 167 | + /** |
|
| 168 | + * Whether or not file name and line number will be included in the output. |
|
| 169 | + * @return boolean |
|
| 170 | + */ |
|
| 171 | + public function getLocationInfo() { |
|
| 172 | + return $this->locationInfo; |
|
| 173 | + } |
|
| 174 | 174 | |
| 175 | - /** |
|
| 176 | - * The {@link $locationInfo} option takes a boolean value. By default, |
|
| 177 | - * it is set to false which means there will be no location |
|
| 178 | - * information output by this layout. If the the option is set to |
|
| 179 | - * true, then the file name and line number of the statement at the |
|
| 180 | - * origin of the log statement will be output. |
|
| 181 | - */ |
|
| 182 | - public function setLocationInfo($flag) { |
|
| 183 | - $this->setBoolean('locationInfo', $flag); |
|
| 184 | - } |
|
| 175 | + /** |
|
| 176 | + * The {@link $locationInfo} option takes a boolean value. By default, |
|
| 177 | + * it is set to false which means there will be no location |
|
| 178 | + * information output by this layout. If the the option is set to |
|
| 179 | + * true, then the file name and line number of the statement at the |
|
| 180 | + * origin of the log statement will be output. |
|
| 181 | + */ |
|
| 182 | + public function setLocationInfo($flag) { |
|
| 183 | + $this->setBoolean('locationInfo', $flag); |
|
| 184 | + } |
|
| 185 | 185 | |
| 186 | - /** |
|
| 187 | - * @return boolean |
|
| 188 | - */ |
|
| 189 | - public function getLog4jNamespace() { |
|
| 190 | - return $this->log4jNamespace; |
|
| 191 | - } |
|
| 186 | + /** |
|
| 187 | + * @return boolean |
|
| 188 | + */ |
|
| 189 | + public function getLog4jNamespace() { |
|
| 190 | + return $this->log4jNamespace; |
|
| 191 | + } |
|
| 192 | 192 | |
| 193 | - /** |
|
| 194 | - * @param boolean |
|
| 195 | - */ |
|
| 196 | - public function setLog4jNamespace($flag) { |
|
| 197 | - $this->setBoolean('log4jNamespace', $flag); |
|
| 198 | - } |
|
| 193 | + /** |
|
| 194 | + * @param boolean |
|
| 195 | + */ |
|
| 196 | + public function setLog4jNamespace($flag) { |
|
| 197 | + $this->setBoolean('log4jNamespace', $flag); |
|
| 198 | + } |
|
| 199 | 199 | |
| 200 | - /** |
|
| 201 | - * Encases a string in CDATA tags, and escapes any existing CDATA end |
|
| 202 | - * tags already present in the string. |
|
| 203 | - * @param string $string |
|
| 204 | - */ |
|
| 205 | - private function encodeCDATA($string) { |
|
| 206 | - $string = str_replace(self::CDATA_END, self::CDATA_EMBEDDED_END, $string); |
|
| 207 | - return self::CDATA_START . $string . self::CDATA_END; |
|
| 208 | - } |
|
| 200 | + /** |
|
| 201 | + * Encases a string in CDATA tags, and escapes any existing CDATA end |
|
| 202 | + * tags already present in the string. |
|
| 203 | + * @param string $string |
|
| 204 | + */ |
|
| 205 | + private function encodeCDATA($string) { |
|
| 206 | + $string = str_replace(self::CDATA_END, self::CDATA_EMBEDDED_END, $string); |
|
| 207 | + return self::CDATA_START . $string . self::CDATA_END; |
|
| 208 | + } |
|
| 209 | 209 | } |
| 210 | 210 | |
@@ -54,7 +54,7 @@ discard block |
||
| 54 | 54 | * @subpackage layouts |
| 55 | 55 | */ |
| 56 | 56 | class Payone_Log4php_LoggerLayoutXml extends Payone_Log4php_LoggerLayout { |
| 57 | - const LOG4J_NS_PREFIX ='log4j'; |
|
| 57 | + const LOG4J_NS_PREFIX = 'log4j'; |
|
| 58 | 58 | const LOG4J_NS = 'http://jakarta.apache.org/log4j/'; |
| 59 | 59 | |
| 60 | 60 | const LOG4PHP_NS_PREFIX = 'log4php'; |
@@ -99,10 +99,10 @@ discard block |
||
| 99 | 99 | * @return string |
| 100 | 100 | */ |
| 101 | 101 | public function getHeader() { |
| 102 | - return "<{$this->namespacePrefix}:eventSet ". |
|
| 103 | - "xmlns:{$this->namespacePrefix}=\"{$this->namespace}\" ". |
|
| 104 | - "version=\"0.3\" ". |
|
| 105 | - "includesLocationInfo=\"".($this->getLocationInfo() ? "true" : "false")."\"". |
|
| 102 | + return "<{$this->namespacePrefix}:eventSet " . |
|
| 103 | + "xmlns:{$this->namespacePrefix}=\"{$this->namespace}\" " . |
|
| 104 | + "version=\"0.3\" " . |
|
| 105 | + "includesLocationInfo=\"" . ($this->getLocationInfo() ? "true" : "false") . "\"" . |
|
| 106 | 106 | ">" . PHP_EOL; |
| 107 | 107 | } |
| 108 | 108 | |
@@ -120,38 +120,38 @@ discard block |
||
| 120 | 120 | $thread = $event->getThreadName(); |
| 121 | 121 | $level = $event->getLevel()->toString(); |
| 122 | 122 | |
| 123 | - $buf = "<$ns:event logger=\"{$loggerName}\" level=\"{$level}\" thread=\"{$thread}\" timestamp=\"{$timeStamp}\">".PHP_EOL; |
|
| 123 | + $buf = "<$ns:event logger=\"{$loggerName}\" level=\"{$level}\" thread=\"{$thread}\" timestamp=\"{$timeStamp}\">" . PHP_EOL; |
|
| 124 | 124 | $buf .= "<$ns:message>"; |
| 125 | 125 | $buf .= $this->encodeCDATA($event->getRenderedMessage()); |
| 126 | - $buf .= "</$ns:message>".PHP_EOL; |
|
| 126 | + $buf .= "</$ns:message>" . PHP_EOL; |
|
| 127 | 127 | |
| 128 | 128 | $ndc = $event->getNDC(); |
| 129 | - if(!empty($ndc)) { |
|
| 129 | + if (!empty($ndc)) { |
|
| 130 | 130 | $buf .= "<$ns:NDC><![CDATA["; |
| 131 | 131 | $buf .= $this->encodeCDATA($ndc); |
| 132 | - $buf .= "]]></$ns:NDC>".PHP_EOL; |
|
| 132 | + $buf .= "]]></$ns:NDC>" . PHP_EOL; |
|
| 133 | 133 | } |
| 134 | 134 | |
| 135 | 135 | $mdcMap = $event->getMDCMap(); |
| 136 | 136 | if (!empty($mdcMap)) { |
| 137 | - $buf .= "<$ns:properties>".PHP_EOL; |
|
| 137 | + $buf .= "<$ns:properties>" . PHP_EOL; |
|
| 138 | 138 | foreach ($mdcMap as $name=>$value) { |
| 139 | - $buf .= "<$ns:data name=\"$name\" value=\"$value\" />".PHP_EOL; |
|
| 139 | + $buf .= "<$ns:data name=\"$name\" value=\"$value\" />" . PHP_EOL; |
|
| 140 | 140 | } |
| 141 | - $buf .= "</$ns:properties>".PHP_EOL; |
|
| 141 | + $buf .= "</$ns:properties>" . PHP_EOL; |
|
| 142 | 142 | } |
| 143 | 143 | |
| 144 | 144 | if ($this->getLocationInfo()) { |
| 145 | 145 | $locationInfo = $event->getLocationInformation(); |
| 146 | - $buf .= "<$ns:locationInfo ". |
|
| 147 | - "class=\"" . $locationInfo->getClassName() . "\" ". |
|
| 148 | - "file=\"" . htmlentities($locationInfo->getFileName(), ENT_QUOTES) . "\" ". |
|
| 149 | - "line=\"" . $locationInfo->getLineNumber() . "\" ". |
|
| 146 | + $buf .= "<$ns:locationInfo " . |
|
| 147 | + "class=\"" . $locationInfo->getClassName() . "\" " . |
|
| 148 | + "file=\"" . htmlentities($locationInfo->getFileName(), ENT_QUOTES) . "\" " . |
|
| 149 | + "line=\"" . $locationInfo->getLineNumber() . "\" " . |
|
| 150 | 150 | "method=\"" . $locationInfo->getMethodName() . "\" "; |
| 151 | - $buf .= "/>".PHP_EOL; |
|
| 151 | + $buf .= "/>" . PHP_EOL; |
|
| 152 | 152 | } |
| 153 | 153 | |
| 154 | - $buf .= "</$ns:event>".PHP_EOL; |
|
| 154 | + $buf .= "</$ns:event>" . PHP_EOL; |
|
| 155 | 155 | |
| 156 | 156 | return $buf; |
| 157 | 157 | } |
@@ -35,17 +35,17 @@ |
||
| 35 | 35 | */ |
| 36 | 36 | class Payone_Log4php_LoggerAppenderNull extends Payone_Log4php_LoggerAppender { |
| 37 | 37 | |
| 38 | - /** |
|
| 39 | - * This appender does not require a layout. |
|
| 40 | - */ |
|
| 41 | - protected $requiresLayout = false; |
|
| 38 | + /** |
|
| 39 | + * This appender does not require a layout. |
|
| 40 | + */ |
|
| 41 | + protected $requiresLayout = false; |
|
| 42 | 42 | |
| 43 | - /** |
|
| 44 | - * Do nothing. |
|
| 45 | - * |
|
| 46 | - * @param Payone_Log4php_LoggerLoggingEvent $event |
|
| 47 | - */ |
|
| 48 | - public function append(Payone_Log4php_LoggerLoggingEvent $event) { |
|
| 49 | - } |
|
| 43 | + /** |
|
| 44 | + * Do nothing. |
|
| 45 | + * |
|
| 46 | + * @param Payone_Log4php_LoggerLoggingEvent $event |
|
| 47 | + */ |
|
| 48 | + public function append(Payone_Log4php_LoggerLoggingEvent $event) { |
|
| 49 | + } |
|
| 50 | 50 | } |
| 51 | 51 | |
@@ -49,70 +49,70 @@ |
||
| 49 | 49 | */ |
| 50 | 50 | class Payone_Log4php_LoggerMDC { |
| 51 | 51 | |
| 52 | - /** Holds the context map. */ |
|
| 53 | - private static $map = array(); |
|
| 52 | + /** Holds the context map. */ |
|
| 53 | + private static $map = array(); |
|
| 54 | 54 | |
| 55 | - /** |
|
| 56 | - * Stores a context value as identified with the key parameter into the |
|
| 57 | - * context map. |
|
| 58 | - * |
|
| 59 | - * @param string $key the key |
|
| 60 | - * @param string $value the value |
|
| 61 | - */ |
|
| 62 | - public static function put($key, $value) { |
|
| 63 | - self::$map[$key] = $value; |
|
| 64 | - } |
|
| 55 | + /** |
|
| 56 | + * Stores a context value as identified with the key parameter into the |
|
| 57 | + * context map. |
|
| 58 | + * |
|
| 59 | + * @param string $key the key |
|
| 60 | + * @param string $value the value |
|
| 61 | + */ |
|
| 62 | + public static function put($key, $value) { |
|
| 63 | + self::$map[$key] = $value; |
|
| 64 | + } |
|
| 65 | 65 | |
| 66 | - /** |
|
| 67 | - * Returns the context value identified by the key parameter. |
|
| 68 | - * |
|
| 69 | - * Special key identifiers can be used to map values in the global $_SERVER |
|
| 70 | - * and $_ENV vars. To access them, use 'server.' or 'env.' followed by the |
|
| 71 | - * desired var name as the key. |
|
| 72 | - * |
|
| 73 | - * @param string $key The key. |
|
| 74 | - * @return string The context or an empty string if no context found |
|
| 75 | - * for given key. |
|
| 76 | - */ |
|
| 77 | - public static function get($key) { |
|
| 78 | - if(!empty($key)) { |
|
| 79 | - if(strpos($key, 'server.') === 0) { |
|
| 80 | - $varName = substr($key, 7); |
|
| 81 | - return isset($_SERVER[$varName]) ? $_SERVER[$varName] : ''; |
|
| 82 | - } else if(strpos($key, 'env.') === 0) { |
|
| 83 | - $varName = substr($key, 4); |
|
| 84 | - $value = getenv($varName); |
|
| 85 | - return ($value !== false) ? $value : ''; |
|
| 86 | - } else { |
|
| 87 | - return isset(self::$map[$key]) ? self::$map[$key] : ''; |
|
| 88 | - } |
|
| 89 | - } |
|
| 90 | - return ''; |
|
| 91 | - } |
|
| 66 | + /** |
|
| 67 | + * Returns the context value identified by the key parameter. |
|
| 68 | + * |
|
| 69 | + * Special key identifiers can be used to map values in the global $_SERVER |
|
| 70 | + * and $_ENV vars. To access them, use 'server.' or 'env.' followed by the |
|
| 71 | + * desired var name as the key. |
|
| 72 | + * |
|
| 73 | + * @param string $key The key. |
|
| 74 | + * @return string The context or an empty string if no context found |
|
| 75 | + * for given key. |
|
| 76 | + */ |
|
| 77 | + public static function get($key) { |
|
| 78 | + if(!empty($key)) { |
|
| 79 | + if(strpos($key, 'server.') === 0) { |
|
| 80 | + $varName = substr($key, 7); |
|
| 81 | + return isset($_SERVER[$varName]) ? $_SERVER[$varName] : ''; |
|
| 82 | + } else if(strpos($key, 'env.') === 0) { |
|
| 83 | + $varName = substr($key, 4); |
|
| 84 | + $value = getenv($varName); |
|
| 85 | + return ($value !== false) ? $value : ''; |
|
| 86 | + } else { |
|
| 87 | + return isset(self::$map[$key]) ? self::$map[$key] : ''; |
|
| 88 | + } |
|
| 89 | + } |
|
| 90 | + return ''; |
|
| 91 | + } |
|
| 92 | 92 | |
| 93 | - /** |
|
| 94 | - * Returns the contex map as an array. |
|
| 95 | - * @return array The MDC context map. |
|
| 96 | - */ |
|
| 97 | - public static function getMap() { |
|
| 98 | - return self::$map; |
|
| 99 | - } |
|
| 93 | + /** |
|
| 94 | + * Returns the contex map as an array. |
|
| 95 | + * @return array The MDC context map. |
|
| 96 | + */ |
|
| 97 | + public static function getMap() { |
|
| 98 | + return self::$map; |
|
| 99 | + } |
|
| 100 | 100 | |
| 101 | - /** |
|
| 102 | - * Removes the the context identified by the key parameter. |
|
| 103 | - * |
|
| 104 | - * Only affects user mappings, not $_ENV or $_SERVER. |
|
| 105 | - * |
|
| 106 | - * @param string $key The key to be removed. |
|
| 107 | - */ |
|
| 108 | - public static function remove($key) { |
|
| 109 | - unset(self::$map[$key]); |
|
| 110 | - } |
|
| 101 | + /** |
|
| 102 | + * Removes the the context identified by the key parameter. |
|
| 103 | + * |
|
| 104 | + * Only affects user mappings, not $_ENV or $_SERVER. |
|
| 105 | + * |
|
| 106 | + * @param string $key The key to be removed. |
|
| 107 | + */ |
|
| 108 | + public static function remove($key) { |
|
| 109 | + unset(self::$map[$key]); |
|
| 110 | + } |
|
| 111 | 111 | |
| 112 | - /** |
|
| 113 | - * Clears the mapped diagnostic context. |
|
| 114 | - */ |
|
| 115 | - public static function clear() { |
|
| 116 | - self::$map = array(); |
|
| 117 | - } |
|
| 112 | + /** |
|
| 113 | + * Clears the mapped diagnostic context. |
|
| 114 | + */ |
|
| 115 | + public static function clear() { |
|
| 116 | + self::$map = array(); |
|
| 117 | + } |
|
| 118 | 118 | } |
@@ -75,11 +75,11 @@ |
||
| 75 | 75 | * for given key. |
| 76 | 76 | */ |
| 77 | 77 | public static function get($key) { |
| 78 | - if(!empty($key)) { |
|
| 79 | - if(strpos($key, 'server.') === 0) { |
|
| 78 | + if (!empty($key)) { |
|
| 79 | + if (strpos($key, 'server.') === 0) { |
|
| 80 | 80 | $varName = substr($key, 7); |
| 81 | 81 | return isset($_SERVER[$varName]) ? $_SERVER[$varName] : ''; |
| 82 | - } else if(strpos($key, 'env.') === 0) { |
|
| 82 | + } else if (strpos($key, 'env.') === 0) { |
|
| 83 | 83 | $varName = substr($key, 4); |
| 84 | 84 | $value = getenv($varName); |
| 85 | 85 | return ($value !== false) ? $value : ''; |
@@ -26,7 +26,7 @@ |
||
| 26 | 26 | */ |
| 27 | 27 | class Payone_Log4php_LoggerPatternConverterProcess extends Payone_Log4php_LoggerPatternConverter { |
| 28 | 28 | |
| 29 | - public function convert(Payone_Log4php_LoggerLoggingEvent $event) { |
|
| 30 | - return getmypid(); |
|
| 31 | - } |
|
| 29 | + public function convert(Payone_Log4php_LoggerLoggingEvent $event) { |
|
| 30 | + return getmypid(); |
|
| 31 | + } |
|
| 32 | 32 | } |