@@ -38,111 +38,111 @@ |
||
| 38 | 38 | */ |
| 39 | 39 | class LoggerAppenderMail extends LoggerAppenderSkeleton { |
| 40 | 40 | |
| 41 | - /** |
|
| 42 | - * @var string 'from' field |
|
| 43 | - */ |
|
| 44 | - public $from = null; |
|
| 41 | + /** |
|
| 42 | + * @var string 'from' field |
|
| 43 | + */ |
|
| 44 | + public $from = null; |
|
| 45 | 45 | |
| 46 | - /** |
|
| 47 | - * @var string 'subject' field |
|
| 48 | - */ |
|
| 49 | - public $subject = 'Log4php Report'; |
|
| 46 | + /** |
|
| 47 | + * @var string 'subject' field |
|
| 48 | + */ |
|
| 49 | + public $subject = 'Log4php Report'; |
|
| 50 | 50 | |
| 51 | - /** |
|
| 52 | - * @var string 'to' field |
|
| 53 | - */ |
|
| 54 | - public $to = null; |
|
| 51 | + /** |
|
| 52 | + * @var string 'to' field |
|
| 53 | + */ |
|
| 54 | + public $to = null; |
|
| 55 | 55 | |
| 56 | - /** |
|
| 57 | - * @var string used to create mail body |
|
| 58 | - * @access private |
|
| 59 | - */ |
|
| 60 | - public $body = ''; |
|
| 56 | + /** |
|
| 57 | + * @var string used to create mail body |
|
| 58 | + * @access private |
|
| 59 | + */ |
|
| 60 | + public $body = ''; |
|
| 61 | 61 | |
| 62 | - /** |
|
| 63 | - * @access private |
|
| 64 | - */ |
|
| 65 | - public $requiresLayout = true; |
|
| 62 | + /** |
|
| 63 | + * @access private |
|
| 64 | + */ |
|
| 65 | + public $requiresLayout = true; |
|
| 66 | 66 | |
| 67 | - /** |
|
| 68 | - * Constructor. |
|
| 69 | - * |
|
| 70 | - * @param string $name appender name |
|
| 71 | - */ |
|
| 72 | - public function LoggerAppenderMail($name) |
|
| 73 | - { |
|
| 74 | - $this->LoggerAppenderSkeleton($name); |
|
| 75 | - } |
|
| 67 | + /** |
|
| 68 | + * Constructor. |
|
| 69 | + * |
|
| 70 | + * @param string $name appender name |
|
| 71 | + */ |
|
| 72 | + public function LoggerAppenderMail($name) |
|
| 73 | + { |
|
| 74 | + $this->LoggerAppenderSkeleton($name); |
|
| 75 | + } |
|
| 76 | 76 | |
| 77 | - public function activateOptions() |
|
| 78 | - { |
|
| 79 | - $this->closed = false; |
|
| 80 | - return; |
|
| 81 | - } |
|
| 77 | + public function activateOptions() |
|
| 78 | + { |
|
| 79 | + $this->closed = false; |
|
| 80 | + return; |
|
| 81 | + } |
|
| 82 | 82 | |
| 83 | - public function close() |
|
| 84 | - { |
|
| 85 | - $from = $this->getFrom(); |
|
| 86 | - $to = $this->getTo(); |
|
| 83 | + public function close() |
|
| 84 | + { |
|
| 85 | + $from = $this->getFrom(); |
|
| 86 | + $to = $this->getTo(); |
|
| 87 | 87 | |
| 88 | - if (!empty($this->body) && $from !== null && $to !== null && $this->layout !== null) { |
|
| 88 | + if (!empty($this->body) && $from !== null && $to !== null && $this->layout !== null) { |
|
| 89 | 89 | |
| 90 | - $subject = $this->getSubject(); |
|
| 90 | + $subject = $this->getSubject(); |
|
| 91 | 91 | |
| 92 | - LoggerLog::debug("LoggerAppenderMail::close() sending mail from=[{$from}] to=[{$to}] subject=[{$subject}]"); |
|
| 92 | + LoggerLog::debug("LoggerAppenderMail::close() sending mail from=[{$from}] to=[{$to}] subject=[{$subject}]"); |
|
| 93 | 93 | |
| 94 | - @mail( |
|
| 95 | - $to, $subject, |
|
| 96 | - $this->layout->getHeader() . $this->body . $this->layout->getFooter(), |
|
| 97 | - "From: {$from}\r\n" |
|
| 98 | - ); |
|
| 99 | - } |
|
| 100 | - $this->closed = true; |
|
| 101 | - } |
|
| 94 | + @mail( |
|
| 95 | + $to, $subject, |
|
| 96 | + $this->layout->getHeader() . $this->body . $this->layout->getFooter(), |
|
| 97 | + "From: {$from}\r\n" |
|
| 98 | + ); |
|
| 99 | + } |
|
| 100 | + $this->closed = true; |
|
| 101 | + } |
|
| 102 | 102 | |
| 103 | - /** |
|
| 104 | - * @return string |
|
| 105 | - */ |
|
| 106 | - public function getFrom() |
|
| 107 | - { |
|
| 108 | - return $this->from; |
|
| 109 | - } |
|
| 103 | + /** |
|
| 104 | + * @return string |
|
| 105 | + */ |
|
| 106 | + public function getFrom() |
|
| 107 | + { |
|
| 108 | + return $this->from; |
|
| 109 | + } |
|
| 110 | 110 | |
| 111 | - /** |
|
| 112 | - * @return string |
|
| 113 | - */ |
|
| 114 | - public function getSubject() |
|
| 115 | - { |
|
| 116 | - return $this->subject; |
|
| 117 | - } |
|
| 111 | + /** |
|
| 112 | + * @return string |
|
| 113 | + */ |
|
| 114 | + public function getSubject() |
|
| 115 | + { |
|
| 116 | + return $this->subject; |
|
| 117 | + } |
|
| 118 | 118 | |
| 119 | - /** |
|
| 120 | - * @return string |
|
| 121 | - */ |
|
| 122 | - public function getTo() |
|
| 123 | - { |
|
| 124 | - return $this->to; |
|
| 125 | - } |
|
| 119 | + /** |
|
| 120 | + * @return string |
|
| 121 | + */ |
|
| 122 | + public function getTo() |
|
| 123 | + { |
|
| 124 | + return $this->to; |
|
| 125 | + } |
|
| 126 | 126 | |
| 127 | - public function setSubject($subject) |
|
| 128 | - { |
|
| 129 | - $this->subject = $subject; |
|
| 130 | - } |
|
| 127 | + public function setSubject($subject) |
|
| 128 | + { |
|
| 129 | + $this->subject = $subject; |
|
| 130 | + } |
|
| 131 | 131 | |
| 132 | - public function setTo($to) |
|
| 133 | - { |
|
| 134 | - $this->to = $to; |
|
| 135 | - } |
|
| 132 | + public function setTo($to) |
|
| 133 | + { |
|
| 134 | + $this->to = $to; |
|
| 135 | + } |
|
| 136 | 136 | |
| 137 | - public function setFrom($from) |
|
| 138 | - { |
|
| 139 | - $this->from = $from; |
|
| 140 | - } |
|
| 137 | + public function setFrom($from) |
|
| 138 | + { |
|
| 139 | + $this->from = $from; |
|
| 140 | + } |
|
| 141 | 141 | |
| 142 | - public function append($event) |
|
| 143 | - { |
|
| 144 | - if ($this->layout !== null) |
|
| 145 | - $this->body .= $this->layout->format($event); |
|
| 146 | - } |
|
| 142 | + public function append($event) |
|
| 143 | + { |
|
| 144 | + if ($this->layout !== null) |
|
| 145 | + $this->body .= $this->layout->format($event); |
|
| 146 | + } |
|
| 147 | 147 | } |
| 148 | 148 | ?> |
| 149 | 149 | \ No newline at end of file |
@@ -39,146 +39,146 @@ |
||
| 39 | 39 | */ |
| 40 | 40 | class LoggerAppenderFile extends LoggerAppenderSkeleton { |
| 41 | 41 | |
| 42 | - /** |
|
| 43 | - * @var boolean if {@link $file} exists, appends events. |
|
| 44 | - */ |
|
| 45 | - public $append = true; |
|
| 42 | + /** |
|
| 43 | + * @var boolean if {@link $file} exists, appends events. |
|
| 44 | + */ |
|
| 45 | + public $append = true; |
|
| 46 | 46 | |
| 47 | - /** |
|
| 48 | - * @var string the file name used to append events |
|
| 49 | - */ |
|
| 50 | - public $fileName; |
|
| 47 | + /** |
|
| 48 | + * @var string the file name used to append events |
|
| 49 | + */ |
|
| 50 | + public $fileName; |
|
| 51 | 51 | |
| 52 | - /** |
|
| 53 | - * @var mixed file resource |
|
| 54 | - * @access private |
|
| 55 | - */ |
|
| 56 | - public $fp = false; |
|
| 52 | + /** |
|
| 53 | + * @var mixed file resource |
|
| 54 | + * @access private |
|
| 55 | + */ |
|
| 56 | + public $fp = false; |
|
| 57 | 57 | |
| 58 | - /** |
|
| 59 | - * @access private |
|
| 60 | - */ |
|
| 61 | - public $requiresLayout = true; |
|
| 58 | + /** |
|
| 59 | + * @access private |
|
| 60 | + */ |
|
| 61 | + public $requiresLayout = true; |
|
| 62 | 62 | |
| 63 | - /** |
|
| 64 | - * Constructor. |
|
| 65 | - * |
|
| 66 | - * @param string $name appender name |
|
| 67 | - */ |
|
| 68 | - public function LoggerAppenderFile($name) |
|
| 69 | - { |
|
| 70 | - $this->LoggerAppenderSkeleton($name); |
|
| 71 | - } |
|
| 63 | + /** |
|
| 64 | + * Constructor. |
|
| 65 | + * |
|
| 66 | + * @param string $name appender name |
|
| 67 | + */ |
|
| 68 | + public function LoggerAppenderFile($name) |
|
| 69 | + { |
|
| 70 | + $this->LoggerAppenderSkeleton($name); |
|
| 71 | + } |
|
| 72 | 72 | |
| 73 | - public function activateOptions() |
|
| 74 | - { |
|
| 75 | - $fileName = $this->getFile(); |
|
| 76 | - LoggerLog::debug("LoggerAppenderFile::activateOptions() opening file '{$fileName}'"); |
|
| 77 | - $this->fp = @fopen($fileName, ($this->getAppend()? 'a':'w')); |
|
| 73 | + public function activateOptions() |
|
| 74 | + { |
|
| 75 | + $fileName = $this->getFile(); |
|
| 76 | + LoggerLog::debug("LoggerAppenderFile::activateOptions() opening file '{$fileName}'"); |
|
| 77 | + $this->fp = @fopen($fileName, ($this->getAppend()? 'a':'w')); |
|
| 78 | 78 | |
| 79 | 79 | // Denying read option for log file. Added for Vulnerability fix |
| 80 | 80 | if (is_readable($fileName)) chmod ($fileName,0222); |
| 81 | 81 | |
| 82 | - if ($this->fp) { |
|
| 83 | - if ($this->getAppend()) |
|
| 84 | - fseek($this->fp, 0, SEEK_END); |
|
| 85 | - @fwrite($this->fp, $this->layout->getHeader()); |
|
| 86 | - $this->closed = false; |
|
| 87 | - } else { |
|
| 88 | - $this->closed = true; |
|
| 89 | - } |
|
| 90 | - } |
|
| 82 | + if ($this->fp) { |
|
| 83 | + if ($this->getAppend()) |
|
| 84 | + fseek($this->fp, 0, SEEK_END); |
|
| 85 | + @fwrite($this->fp, $this->layout->getHeader()); |
|
| 86 | + $this->closed = false; |
|
| 87 | + } else { |
|
| 88 | + $this->closed = true; |
|
| 89 | + } |
|
| 90 | + } |
|
| 91 | 91 | |
| 92 | - public function close() |
|
| 93 | - { |
|
| 94 | - if ($this->fp && $this->layout !== null) |
|
| 95 | - @fwrite($this->fp, $this->layout->getFooter()); |
|
| 92 | + public function close() |
|
| 93 | + { |
|
| 94 | + if ($this->fp && $this->layout !== null) |
|
| 95 | + @fwrite($this->fp, $this->layout->getFooter()); |
|
| 96 | 96 | |
| 97 | - $this->closeFile(); |
|
| 98 | - $this->closed = true; |
|
| 99 | - } |
|
| 97 | + $this->closeFile(); |
|
| 98 | + $this->closed = true; |
|
| 99 | + } |
|
| 100 | 100 | |
| 101 | - /** |
|
| 102 | - * Closes the previously opened file. |
|
| 103 | - */ |
|
| 104 | - public function closeFile() |
|
| 105 | - { |
|
| 106 | - if ($this->fp) |
|
| 107 | - @fclose($this->fp); |
|
| 108 | - } |
|
| 101 | + /** |
|
| 102 | + * Closes the previously opened file. |
|
| 103 | + */ |
|
| 104 | + public function closeFile() |
|
| 105 | + { |
|
| 106 | + if ($this->fp) |
|
| 107 | + @fclose($this->fp); |
|
| 108 | + } |
|
| 109 | 109 | |
| 110 | - /** |
|
| 111 | - * @return boolean |
|
| 112 | - */ |
|
| 113 | - public function getAppend() |
|
| 114 | - { |
|
| 115 | - return $this->append; |
|
| 116 | - } |
|
| 110 | + /** |
|
| 111 | + * @return boolean |
|
| 112 | + */ |
|
| 113 | + public function getAppend() |
|
| 114 | + { |
|
| 115 | + return $this->append; |
|
| 116 | + } |
|
| 117 | 117 | |
| 118 | - /** |
|
| 119 | - * @return string |
|
| 120 | - */ |
|
| 121 | - public function getFile() |
|
| 122 | - { |
|
| 123 | - return $this->getFileName(); |
|
| 124 | - } |
|
| 118 | + /** |
|
| 119 | + * @return string |
|
| 120 | + */ |
|
| 121 | + public function getFile() |
|
| 122 | + { |
|
| 123 | + return $this->getFileName(); |
|
| 124 | + } |
|
| 125 | 125 | |
| 126 | - /** |
|
| 127 | - * @return string |
|
| 128 | - */ |
|
| 129 | - public function getFileName() |
|
| 130 | - { |
|
| 131 | - return $this->fileName; |
|
| 132 | - } |
|
| 126 | + /** |
|
| 127 | + * @return string |
|
| 128 | + */ |
|
| 129 | + public function getFileName() |
|
| 130 | + { |
|
| 131 | + return $this->fileName; |
|
| 132 | + } |
|
| 133 | 133 | |
| 134 | - /** |
|
| 135 | - * Close any previously opened file and call the parent's reset. |
|
| 136 | - */ |
|
| 137 | - public function reset() |
|
| 138 | - { |
|
| 139 | - $this->closeFile(); |
|
| 140 | - $this->fileName = null; |
|
| 141 | - parent::reset(); |
|
| 142 | - } |
|
| 134 | + /** |
|
| 135 | + * Close any previously opened file and call the parent's reset. |
|
| 136 | + */ |
|
| 137 | + public function reset() |
|
| 138 | + { |
|
| 139 | + $this->closeFile(); |
|
| 140 | + $this->fileName = null; |
|
| 141 | + parent::reset(); |
|
| 142 | + } |
|
| 143 | 143 | |
| 144 | - public function setAppend($flag) |
|
| 145 | - { |
|
| 146 | - $this->append = LoggerOptionConverter::toBoolean($flag, true); |
|
| 147 | - } |
|
| 144 | + public function setAppend($flag) |
|
| 145 | + { |
|
| 146 | + $this->append = LoggerOptionConverter::toBoolean($flag, true); |
|
| 147 | + } |
|
| 148 | 148 | |
| 149 | - /** |
|
| 150 | - * Sets and opens the file where the log output will go. |
|
| 151 | - * |
|
| 152 | - * This is an overloaded method. It can be called with: |
|
| 153 | - * - setFile(string $fileName) to set filename. |
|
| 154 | - * - setFile(string $fileName, boolean $append) to set filename and append. |
|
| 155 | - */ |
|
| 156 | - public function setFile() |
|
| 157 | - { |
|
| 158 | - $numargs = func_num_args(); |
|
| 159 | - $args = func_get_args(); |
|
| 149 | + /** |
|
| 150 | + * Sets and opens the file where the log output will go. |
|
| 151 | + * |
|
| 152 | + * This is an overloaded method. It can be called with: |
|
| 153 | + * - setFile(string $fileName) to set filename. |
|
| 154 | + * - setFile(string $fileName, boolean $append) to set filename and append. |
|
| 155 | + */ |
|
| 156 | + public function setFile() |
|
| 157 | + { |
|
| 158 | + $numargs = func_num_args(); |
|
| 159 | + $args = func_get_args(); |
|
| 160 | 160 | |
| 161 | - if ($numargs == 1 && is_string($args[0])) { |
|
| 162 | - $this->setFileName($args[0]); |
|
| 163 | - } elseif ($numargs >=2 && is_string($args[0]) && is_bool($args[1])) { |
|
| 164 | - $this->setFile($args[0]); |
|
| 165 | - $this->setAppend($args[1]); |
|
| 166 | - } |
|
| 167 | - } |
|
| 161 | + if ($numargs == 1 && is_string($args[0])) { |
|
| 162 | + $this->setFileName($args[0]); |
|
| 163 | + } elseif ($numargs >=2 && is_string($args[0]) && is_bool($args[1])) { |
|
| 164 | + $this->setFile($args[0]); |
|
| 165 | + $this->setAppend($args[1]); |
|
| 166 | + } |
|
| 167 | + } |
|
| 168 | 168 | |
| 169 | - public function setFileName($fileName) |
|
| 170 | - { |
|
| 171 | - $this->fileName = $fileName; |
|
| 172 | - } |
|
| 169 | + public function setFileName($fileName) |
|
| 170 | + { |
|
| 171 | + $this->fileName = $fileName; |
|
| 172 | + } |
|
| 173 | 173 | |
| 174 | - public function append($event) |
|
| 175 | - { |
|
| 176 | - if ($this->fp && $this->layout !== null) { |
|
| 174 | + public function append($event) |
|
| 175 | + { |
|
| 176 | + if ($this->fp && $this->layout !== null) { |
|
| 177 | 177 | |
| 178 | - LoggerLog::debug("LoggerAppenderFile::append()"); |
|
| 178 | + LoggerLog::debug("LoggerAppenderFile::append()"); |
|
| 179 | 179 | |
| 180 | - @fwrite($this->fp, $this->layout->format($event)); |
|
| 181 | - } |
|
| 182 | - } |
|
| 180 | + @fwrite($this->fp, $this->layout->format($event)); |
|
| 181 | + } |
|
| 182 | + } |
|
| 183 | 183 | } |
| 184 | 184 | ?> |
@@ -35,38 +35,38 @@ |
||
| 35 | 35 | */ |
| 36 | 36 | class LoggerAppenderNull extends LoggerAppenderSkeleton { |
| 37 | 37 | |
| 38 | - /** |
|
| 39 | - * @access private |
|
| 40 | - */ |
|
| 41 | - public $requiresLayout = false; |
|
| 38 | + /** |
|
| 39 | + * @access private |
|
| 40 | + */ |
|
| 41 | + public $requiresLayout = false; |
|
| 42 | 42 | |
| 43 | - /** |
|
| 44 | - * Constructor. |
|
| 45 | - * |
|
| 46 | - * @param string $name appender name |
|
| 47 | - */ |
|
| 48 | - public function LoggerAppenderNull($name) |
|
| 49 | - { |
|
| 50 | - $this->LoggerAppenderSkeleton($name); |
|
| 51 | - } |
|
| 43 | + /** |
|
| 44 | + * Constructor. |
|
| 45 | + * |
|
| 46 | + * @param string $name appender name |
|
| 47 | + */ |
|
| 48 | + public function LoggerAppenderNull($name) |
|
| 49 | + { |
|
| 50 | + $this->LoggerAppenderSkeleton($name); |
|
| 51 | + } |
|
| 52 | 52 | |
| 53 | - public function activateOptions() |
|
| 54 | - { |
|
| 55 | - $this->closed = false; |
|
| 56 | - } |
|
| 53 | + public function activateOptions() |
|
| 54 | + { |
|
| 55 | + $this->closed = false; |
|
| 56 | + } |
|
| 57 | 57 | |
| 58 | - public function close() |
|
| 59 | - { |
|
| 60 | - $this->closed = true; |
|
| 61 | - } |
|
| 58 | + public function close() |
|
| 59 | + { |
|
| 60 | + $this->closed = true; |
|
| 61 | + } |
|
| 62 | 62 | |
| 63 | - /** |
|
| 64 | - * Do nothing. How I Love it !! :) |
|
| 65 | - */ |
|
| 66 | - public function append($event) |
|
| 67 | - { |
|
| 68 | - LoggerLog::debug("LoggerAppenderNull::append()"); |
|
| 69 | - } |
|
| 63 | + /** |
|
| 64 | + * Do nothing. How I Love it !! :) |
|
| 65 | + */ |
|
| 66 | + public function append($event) |
|
| 67 | + { |
|
| 68 | + LoggerLog::debug("LoggerAppenderNull::append()"); |
|
| 69 | + } |
|
| 70 | 70 | } |
| 71 | 71 | |
| 72 | 72 | ?> |
| 73 | 73 | \ No newline at end of file |
@@ -39,51 +39,51 @@ |
||
| 39 | 39 | */ |
| 40 | 40 | class LoggerAppenderEcho extends LoggerAppenderSkeleton { |
| 41 | 41 | |
| 42 | - /** |
|
| 43 | - * @access private |
|
| 44 | - */ |
|
| 45 | - public $requiresLayout = true; |
|
| 42 | + /** |
|
| 43 | + * @access private |
|
| 44 | + */ |
|
| 45 | + public $requiresLayout = true; |
|
| 46 | 46 | |
| 47 | - /** |
|
| 48 | - * @var boolean used internally to mark first append |
|
| 49 | - * @access private |
|
| 50 | - */ |
|
| 51 | - public $firstAppend = true; |
|
| 47 | + /** |
|
| 48 | + * @var boolean used internally to mark first append |
|
| 49 | + * @access private |
|
| 50 | + */ |
|
| 51 | + public $firstAppend = true; |
|
| 52 | 52 | |
| 53 | - /** |
|
| 54 | - * Constructor. |
|
| 55 | - * |
|
| 56 | - * @param string $name appender name |
|
| 57 | - */ |
|
| 58 | - public function LoggerAppenderEcho($name) |
|
| 59 | - { |
|
| 60 | - $this->LoggerAppenderSkeleton($name); |
|
| 61 | - } |
|
| 53 | + /** |
|
| 54 | + * Constructor. |
|
| 55 | + * |
|
| 56 | + * @param string $name appender name |
|
| 57 | + */ |
|
| 58 | + public function LoggerAppenderEcho($name) |
|
| 59 | + { |
|
| 60 | + $this->LoggerAppenderSkeleton($name); |
|
| 61 | + } |
|
| 62 | 62 | |
| 63 | - public function activateOptions() |
|
| 64 | - { |
|
| 65 | - return; |
|
| 66 | - } |
|
| 63 | + public function activateOptions() |
|
| 64 | + { |
|
| 65 | + return; |
|
| 66 | + } |
|
| 67 | 67 | |
| 68 | - public function close() |
|
| 69 | - { |
|
| 70 | - if (!$this->firstAppend) |
|
| 71 | - echo $this->layout->getFooter(); |
|
| 72 | - $this->closed = true; |
|
| 73 | - } |
|
| 68 | + public function close() |
|
| 69 | + { |
|
| 70 | + if (!$this->firstAppend) |
|
| 71 | + echo $this->layout->getFooter(); |
|
| 72 | + $this->closed = true; |
|
| 73 | + } |
|
| 74 | 74 | |
| 75 | - public function append($event) |
|
| 76 | - { |
|
| 77 | - LoggerLog::debug("LoggerAppenderEcho::append()"); |
|
| 75 | + public function append($event) |
|
| 76 | + { |
|
| 77 | + LoggerLog::debug("LoggerAppenderEcho::append()"); |
|
| 78 | 78 | |
| 79 | - if ($this->layout !== null) { |
|
| 80 | - if ($this->firstAppend) { |
|
| 81 | - echo $this->layout->getHeader(); |
|
| 82 | - $this->firstAppend = false; |
|
| 83 | - } |
|
| 84 | - echo $this->layout->format($event); |
|
| 85 | - } |
|
| 86 | - } |
|
| 79 | + if ($this->layout !== null) { |
|
| 80 | + if ($this->firstAppend) { |
|
| 81 | + echo $this->layout->getHeader(); |
|
| 82 | + $this->firstAppend = false; |
|
| 83 | + } |
|
| 84 | + echo $this->layout->format($event); |
|
| 85 | + } |
|
| 86 | + } |
|
| 87 | 87 | } |
| 88 | 88 | |
| 89 | 89 | ?> |
| 90 | 90 | \ No newline at end of file |
@@ -48,7 +48,7 @@ |
||
| 48 | 48 | * @var boolean used internally to mark first append |
| 49 | 49 | * @access private |
| 50 | 50 | */ |
| 51 | - public $firstAppend = true; |
|
| 51 | + public $firstAppend = true; |
|
| 52 | 52 | |
| 53 | 53 | /** |
| 54 | 54 | * Constructor. |
@@ -40,57 +40,57 @@ |
||
| 40 | 40 | */ |
| 41 | 41 | class LoggerAppenderDailyFile extends LoggerAppenderFile { |
| 42 | 42 | |
| 43 | - /** |
|
| 44 | - * Format date. |
|
| 45 | - * It follows the {@link PHP_MANUAL#date()} formatting rules and <b>should always be set before {@link $file} param</b>. |
|
| 46 | - * @var string |
|
| 47 | - */ |
|
| 48 | - public $datePattern = "Ymd"; |
|
| 43 | + /** |
|
| 44 | + * Format date. |
|
| 45 | + * It follows the {@link PHP_MANUAL#date()} formatting rules and <b>should always be set before {@link $file} param</b>. |
|
| 46 | + * @var string |
|
| 47 | + */ |
|
| 48 | + public $datePattern = "Ymd"; |
|
| 49 | 49 | |
| 50 | - /** |
|
| 51 | - * Constructor |
|
| 52 | - * |
|
| 53 | - * @param string $name appender name |
|
| 54 | - */ |
|
| 55 | - public function LoggerAppenderDailyFile($name) |
|
| 56 | - { |
|
| 57 | - $this->LoggerAppenderFile($name); |
|
| 58 | - } |
|
| 50 | + /** |
|
| 51 | + * Constructor |
|
| 52 | + * |
|
| 53 | + * @param string $name appender name |
|
| 54 | + */ |
|
| 55 | + public function LoggerAppenderDailyFile($name) |
|
| 56 | + { |
|
| 57 | + $this->LoggerAppenderFile($name); |
|
| 58 | + } |
|
| 59 | 59 | |
| 60 | - /** |
|
| 61 | - * Sets date format for the file name. |
|
| 62 | - * @param string $format a regular date() string format |
|
| 63 | - */ |
|
| 64 | - public function setDatePattern ( $format ) |
|
| 65 | - { |
|
| 66 | - $this->datePattern = $format; |
|
| 67 | - } |
|
| 60 | + /** |
|
| 61 | + * Sets date format for the file name. |
|
| 62 | + * @param string $format a regular date() string format |
|
| 63 | + */ |
|
| 64 | + public function setDatePattern ( $format ) |
|
| 65 | + { |
|
| 66 | + $this->datePattern = $format; |
|
| 67 | + } |
|
| 68 | 68 | |
| 69 | - /** |
|
| 70 | - * @return string returns date format for the filename |
|
| 71 | - */ |
|
| 72 | - public function getDatePattern ( ) |
|
| 73 | - { |
|
| 74 | - return $this->datePattern; |
|
| 75 | - } |
|
| 69 | + /** |
|
| 70 | + * @return string returns date format for the filename |
|
| 71 | + */ |
|
| 72 | + public function getDatePattern ( ) |
|
| 73 | + { |
|
| 74 | + return $this->datePattern; |
|
| 75 | + } |
|
| 76 | 76 | |
| 77 | - /** |
|
| 78 | - * The File property takes a string value which should be the name of the file to append to. |
|
| 79 | - * Sets and opens the file where the log output will go. |
|
| 80 | - * |
|
| 81 | - * @see LoggerAppenderFile::setFile() |
|
| 82 | - */ |
|
| 83 | - public function setFile() |
|
| 84 | - { |
|
| 85 | - $numargs = func_num_args(); |
|
| 86 | - $args = func_get_args(); |
|
| 77 | + /** |
|
| 78 | + * The File property takes a string value which should be the name of the file to append to. |
|
| 79 | + * Sets and opens the file where the log output will go. |
|
| 80 | + * |
|
| 81 | + * @see LoggerAppenderFile::setFile() |
|
| 82 | + */ |
|
| 83 | + public function setFile() |
|
| 84 | + { |
|
| 85 | + $numargs = func_num_args(); |
|
| 86 | + $args = func_get_args(); |
|
| 87 | 87 | |
| 88 | - if ($numargs == 1 && is_string($args[0])) { |
|
| 89 | - parent::setFile( sprintf((string)$args[0], date($this->getDatePattern())) ); |
|
| 90 | - } elseif ($numargs == 2 && is_string($args[0]) && is_bool($args[1])) { |
|
| 91 | - parent::setFile( sprintf((string)$args[0], date($this->getDatePattern())), $args[1] ); |
|
| 92 | - } |
|
| 93 | - } |
|
| 88 | + if ($numargs == 1 && is_string($args[0])) { |
|
| 89 | + parent::setFile( sprintf((string)$args[0], date($this->getDatePattern())) ); |
|
| 90 | + } elseif ($numargs == 2 && is_string($args[0]) && is_bool($args[1])) { |
|
| 91 | + parent::setFile( sprintf((string)$args[0], date($this->getDatePattern())), $args[1] ); |
|
| 92 | + } |
|
| 93 | + } |
|
| 94 | 94 | |
| 95 | 95 | } |
| 96 | 96 | |
@@ -39,203 +39,203 @@ |
||
| 39 | 39 | */ |
| 40 | 40 | class LoggerAppenderRollingFile extends LoggerAppenderFile { |
| 41 | 41 | |
| 42 | - /** |
|
| 43 | - * Set the maximum size that the output file is allowed to reach |
|
| 44 | - * before being rolled over to backup files. |
|
| 45 | - * |
|
| 46 | - * <p>In configuration files, the <var>MaxFileSize</var> option takes a |
|
| 47 | - * long integer in the range 0 - 2^63. You can specify the value |
|
| 48 | - * with the suffixes "KB", "MB" or "GB" so that the integer is |
|
| 49 | - * interpreted being expressed respectively in kilobytes, megabytes |
|
| 50 | - * or gigabytes. For example, the value "10KB" will be interpreted |
|
| 51 | - * as 10240.</p> |
|
| 52 | - * <p>The default maximum file size is 10MB.</p> |
|
| 53 | - * |
|
| 54 | - * <p>Note that MaxFileSize cannot exceed <b>2 GB</b>.</p> |
|
| 55 | - * |
|
| 56 | - * @var integer |
|
| 57 | - */ |
|
| 58 | - public $maxFileSize = 10485760; |
|
| 42 | + /** |
|
| 43 | + * Set the maximum size that the output file is allowed to reach |
|
| 44 | + * before being rolled over to backup files. |
|
| 45 | + * |
|
| 46 | + * <p>In configuration files, the <var>MaxFileSize</var> option takes a |
|
| 47 | + * long integer in the range 0 - 2^63. You can specify the value |
|
| 48 | + * with the suffixes "KB", "MB" or "GB" so that the integer is |
|
| 49 | + * interpreted being expressed respectively in kilobytes, megabytes |
|
| 50 | + * or gigabytes. For example, the value "10KB" will be interpreted |
|
| 51 | + * as 10240.</p> |
|
| 52 | + * <p>The default maximum file size is 10MB.</p> |
|
| 53 | + * |
|
| 54 | + * <p>Note that MaxFileSize cannot exceed <b>2 GB</b>.</p> |
|
| 55 | + * |
|
| 56 | + * @var integer |
|
| 57 | + */ |
|
| 58 | + public $maxFileSize = 10485760; |
|
| 59 | 59 | |
| 60 | - /** |
|
| 61 | - * Set the maximum number of backup files to keep around. |
|
| 62 | - * |
|
| 63 | - * <p>The <var>MaxBackupIndex</var> option determines how many backup |
|
| 64 | - * files are kept before the oldest is erased. This option takes |
|
| 65 | - * a positive integer value. If set to zero, then there will be no |
|
| 66 | - * backup files and the log file will be truncated when it reaches |
|
| 67 | - * MaxFileSize.</p> |
|
| 68 | - * <p>There is one backup file by default.</p> |
|
| 69 | - * |
|
| 70 | - * @var integer |
|
| 71 | - */ |
|
| 72 | - public $maxBackupIndex = 1; |
|
| 60 | + /** |
|
| 61 | + * Set the maximum number of backup files to keep around. |
|
| 62 | + * |
|
| 63 | + * <p>The <var>MaxBackupIndex</var> option determines how many backup |
|
| 64 | + * files are kept before the oldest is erased. This option takes |
|
| 65 | + * a positive integer value. If set to zero, then there will be no |
|
| 66 | + * backup files and the log file will be truncated when it reaches |
|
| 67 | + * MaxFileSize.</p> |
|
| 68 | + * <p>There is one backup file by default.</p> |
|
| 69 | + * |
|
| 70 | + * @var integer |
|
| 71 | + */ |
|
| 72 | + public $maxBackupIndex = 1; |
|
| 73 | 73 | |
| 74 | - /** |
|
| 75 | - * @var string the filename expanded |
|
| 76 | - * @access private |
|
| 77 | - */ |
|
| 78 | - public $expandedFileName = null; |
|
| 74 | + /** |
|
| 75 | + * @var string the filename expanded |
|
| 76 | + * @access private |
|
| 77 | + */ |
|
| 78 | + public $expandedFileName = null; |
|
| 79 | 79 | |
| 80 | - /** |
|
| 81 | - * Constructor. |
|
| 82 | - * |
|
| 83 | - * @param string $name appender name |
|
| 84 | - */ |
|
| 85 | - public function LoggerAppenderRollingFile($name) |
|
| 86 | - { |
|
| 87 | - $this->LoggerAppenderFile($name); |
|
| 88 | - } |
|
| 80 | + /** |
|
| 81 | + * Constructor. |
|
| 82 | + * |
|
| 83 | + * @param string $name appender name |
|
| 84 | + */ |
|
| 85 | + public function LoggerAppenderRollingFile($name) |
|
| 86 | + { |
|
| 87 | + $this->LoggerAppenderFile($name); |
|
| 88 | + } |
|
| 89 | 89 | |
| 90 | - /** |
|
| 91 | - * Returns the value of the MaxBackupIndex option. |
|
| 92 | - * @return integer |
|
| 93 | - */ |
|
| 94 | - public function getExpandedFileName() { |
|
| 95 | - return $this->expandedFileName; |
|
| 96 | - } |
|
| 90 | + /** |
|
| 91 | + * Returns the value of the MaxBackupIndex option. |
|
| 92 | + * @return integer |
|
| 93 | + */ |
|
| 94 | + public function getExpandedFileName() { |
|
| 95 | + return $this->expandedFileName; |
|
| 96 | + } |
|
| 97 | 97 | |
| 98 | - /** |
|
| 99 | - * Returns the value of the MaxBackupIndex option. |
|
| 100 | - * @return integer |
|
| 101 | - */ |
|
| 102 | - public function getMaxBackupIndex() { |
|
| 103 | - return $this->maxBackupIndex; |
|
| 104 | - } |
|
| 98 | + /** |
|
| 99 | + * Returns the value of the MaxBackupIndex option. |
|
| 100 | + * @return integer |
|
| 101 | + */ |
|
| 102 | + public function getMaxBackupIndex() { |
|
| 103 | + return $this->maxBackupIndex; |
|
| 104 | + } |
|
| 105 | 105 | |
| 106 | - /** |
|
| 107 | - * Get the maximum size that the output file is allowed to reach |
|
| 108 | - * before being rolled over to backup files. |
|
| 109 | - * @return integer |
|
| 110 | - */ |
|
| 111 | - public function getMaximumFileSize() { |
|
| 112 | - return $this->maxFileSize; |
|
| 113 | - } |
|
| 106 | + /** |
|
| 107 | + * Get the maximum size that the output file is allowed to reach |
|
| 108 | + * before being rolled over to backup files. |
|
| 109 | + * @return integer |
|
| 110 | + */ |
|
| 111 | + public function getMaximumFileSize() { |
|
| 112 | + return $this->maxFileSize; |
|
| 113 | + } |
|
| 114 | 114 | |
| 115 | - /** |
|
| 116 | - * Implements the usual roll over behaviour. |
|
| 117 | - * |
|
| 118 | - * <p>If MaxBackupIndex is positive, then files File.1, ..., File.MaxBackupIndex -1 are renamed to File.2, ..., File.MaxBackupIndex. |
|
| 119 | - * Moreover, File is renamed File.1 and closed. A new File is created to receive further log output. |
|
| 120 | - * |
|
| 121 | - * <p>If MaxBackupIndex is equal to zero, then the File is truncated with no backup files created. |
|
| 122 | - */ |
|
| 123 | - public function rollOver() |
|
| 124 | - { |
|
| 125 | - // If maxBackups <= 0, then there is no file renaming to be done. |
|
| 126 | - if($this->maxBackupIndex > 0) { |
|
| 127 | - $fileName = $this->getExpandedFileName(); |
|
| 128 | - // Delete the oldest file, to keep Windows happy. |
|
| 129 | - $file = $fileName . '.' . $this->maxBackupIndex; |
|
| 130 | - if (is_writable($file)) |
|
| 131 | - unlink($file); |
|
| 132 | - // Map {(maxBackupIndex - 1), ..., 2, 1} to {maxBackupIndex, ..., 3, 2} |
|
| 133 | - for ($i = $this->maxBackupIndex - 1; $i >= 1; $i--) { |
|
| 134 | - $file = $fileName . "." . $i; |
|
| 135 | - if (is_readable($file)) { |
|
| 136 | - $target = $fileName . '.' . ($i + 1); |
|
| 137 | - rename($file, $target); |
|
| 138 | - } |
|
| 139 | - } |
|
| 115 | + /** |
|
| 116 | + * Implements the usual roll over behaviour. |
|
| 117 | + * |
|
| 118 | + * <p>If MaxBackupIndex is positive, then files File.1, ..., File.MaxBackupIndex -1 are renamed to File.2, ..., File.MaxBackupIndex. |
|
| 119 | + * Moreover, File is renamed File.1 and closed. A new File is created to receive further log output. |
|
| 120 | + * |
|
| 121 | + * <p>If MaxBackupIndex is equal to zero, then the File is truncated with no backup files created. |
|
| 122 | + */ |
|
| 123 | + public function rollOver() |
|
| 124 | + { |
|
| 125 | + // If maxBackups <= 0, then there is no file renaming to be done. |
|
| 126 | + if($this->maxBackupIndex > 0) { |
|
| 127 | + $fileName = $this->getExpandedFileName(); |
|
| 128 | + // Delete the oldest file, to keep Windows happy. |
|
| 129 | + $file = $fileName . '.' . $this->maxBackupIndex; |
|
| 130 | + if (is_writable($file)) |
|
| 131 | + unlink($file); |
|
| 132 | + // Map {(maxBackupIndex - 1), ..., 2, 1} to {maxBackupIndex, ..., 3, 2} |
|
| 133 | + for ($i = $this->maxBackupIndex - 1; $i >= 1; $i--) { |
|
| 134 | + $file = $fileName . "." . $i; |
|
| 135 | + if (is_readable($file)) { |
|
| 136 | + $target = $fileName . '.' . ($i + 1); |
|
| 137 | + rename($file, $target); |
|
| 138 | + } |
|
| 139 | + } |
|
| 140 | 140 | |
| 141 | - // Rename fileName to fileName.1 |
|
| 142 | - $target = $fileName . ".1"; |
|
| 141 | + // Rename fileName to fileName.1 |
|
| 142 | + $target = $fileName . ".1"; |
|
| 143 | 143 | |
| 144 | - $this->closeFile(); // keep windows happy. |
|
| 144 | + $this->closeFile(); // keep windows happy. |
|
| 145 | 145 | |
| 146 | - $file = $fileName; |
|
| 146 | + $file = $fileName; |
|
| 147 | 147 | |
| 148 | - //As of now suppress the error in rename. we have to handle in future |
|
| 149 | - @rename($file, $target); |
|
| 150 | - } |
|
| 148 | + //As of now suppress the error in rename. we have to handle in future |
|
| 149 | + @rename($file, $target); |
|
| 150 | + } |
|
| 151 | 151 | |
| 152 | - $this->setFile($fileName, false); |
|
| 153 | - unset($this->fp); |
|
| 154 | - $this->activateOptions(); |
|
| 155 | - } |
|
| 152 | + $this->setFile($fileName, false); |
|
| 153 | + unset($this->fp); |
|
| 154 | + $this->activateOptions(); |
|
| 155 | + } |
|
| 156 | 156 | |
| 157 | - public function setFileName($fileName) |
|
| 158 | - { |
|
| 159 | - $this->fileName = $fileName; |
|
| 160 | - $this->expandedFileName = realpath($fileName); |
|
| 161 | - LoggerLog::debug("LoggerAppenderRollingFile::setFileName():filename=[{$fileName}]:expandedFileName=[{$this->expandedFileName}]"); |
|
| 162 | - } |
|
| 157 | + public function setFileName($fileName) |
|
| 158 | + { |
|
| 159 | + $this->fileName = $fileName; |
|
| 160 | + $this->expandedFileName = realpath($fileName); |
|
| 161 | + LoggerLog::debug("LoggerAppenderRollingFile::setFileName():filename=[{$fileName}]:expandedFileName=[{$this->expandedFileName}]"); |
|
| 162 | + } |
|
| 163 | 163 | |
| 164 | 164 | |
| 165 | - /** |
|
| 166 | - * Set the maximum number of backup files to keep around. |
|
| 167 | - * |
|
| 168 | - * <p>The <b>MaxBackupIndex</b> option determines how many backup |
|
| 169 | - * files are kept before the oldest is erased. This option takes |
|
| 170 | - * a positive integer value. If set to zero, then there will be no |
|
| 171 | - * backup files and the log file will be truncated when it reaches |
|
| 172 | - * MaxFileSize. |
|
| 173 | - * |
|
| 174 | - * @param mixed $maxBackups |
|
| 175 | - */ |
|
| 176 | - public function setMaxBackupIndex($maxBackups) |
|
| 177 | - { |
|
| 178 | - if (is_numeric($maxBackups)) |
|
| 179 | - $this->maxBackupIndex = abs((int)$maxBackups); |
|
| 180 | - } |
|
| 165 | + /** |
|
| 166 | + * Set the maximum number of backup files to keep around. |
|
| 167 | + * |
|
| 168 | + * <p>The <b>MaxBackupIndex</b> option determines how many backup |
|
| 169 | + * files are kept before the oldest is erased. This option takes |
|
| 170 | + * a positive integer value. If set to zero, then there will be no |
|
| 171 | + * backup files and the log file will be truncated when it reaches |
|
| 172 | + * MaxFileSize. |
|
| 173 | + * |
|
| 174 | + * @param mixed $maxBackups |
|
| 175 | + */ |
|
| 176 | + public function setMaxBackupIndex($maxBackups) |
|
| 177 | + { |
|
| 178 | + if (is_numeric($maxBackups)) |
|
| 179 | + $this->maxBackupIndex = abs((int)$maxBackups); |
|
| 180 | + } |
|
| 181 | 181 | |
| 182 | - /** |
|
| 183 | - * Set the maximum size that the output file is allowed to reach |
|
| 184 | - * before being rolled over to backup files. |
|
| 185 | - * |
|
| 186 | - * @param mixed $maxFileSize |
|
| 187 | - * @see setMaxFileSize() |
|
| 188 | - */ |
|
| 189 | - public function setMaximumFileSize($maxFileSize) |
|
| 190 | - { |
|
| 191 | - $this->setMaxFileSize($maxFileSize); |
|
| 192 | - } |
|
| 182 | + /** |
|
| 183 | + * Set the maximum size that the output file is allowed to reach |
|
| 184 | + * before being rolled over to backup files. |
|
| 185 | + * |
|
| 186 | + * @param mixed $maxFileSize |
|
| 187 | + * @see setMaxFileSize() |
|
| 188 | + */ |
|
| 189 | + public function setMaximumFileSize($maxFileSize) |
|
| 190 | + { |
|
| 191 | + $this->setMaxFileSize($maxFileSize); |
|
| 192 | + } |
|
| 193 | 193 | |
| 194 | - /** |
|
| 195 | - * Set the maximum size that the output file is allowed to reach |
|
| 196 | - * before being rolled over to backup files. |
|
| 197 | - * <p>In configuration files, the <b>MaxFileSize</b> option takes an |
|
| 198 | - * long integer in the range 0 - 2^63. You can specify the value |
|
| 199 | - * with the suffixes "KB", "MB" or "GB" so that the integer is |
|
| 200 | - * interpreted being expressed respectively in kilobytes, megabytes |
|
| 201 | - * or gigabytes. For example, the value "10KB" will be interpreted |
|
| 202 | - * as 10240. |
|
| 203 | - * |
|
| 204 | - * @param mixed $value |
|
| 205 | - */ |
|
| 206 | - public function setMaxFileSize($value) |
|
| 207 | - { |
|
| 208 | - $maxFileSize = null; |
|
| 209 | - $numpart = substr($value,0, strlen($value) -2); |
|
| 210 | - $suffix = strtoupper(substr($value, -2)); |
|
| 194 | + /** |
|
| 195 | + * Set the maximum size that the output file is allowed to reach |
|
| 196 | + * before being rolled over to backup files. |
|
| 197 | + * <p>In configuration files, the <b>MaxFileSize</b> option takes an |
|
| 198 | + * long integer in the range 0 - 2^63. You can specify the value |
|
| 199 | + * with the suffixes "KB", "MB" or "GB" so that the integer is |
|
| 200 | + * interpreted being expressed respectively in kilobytes, megabytes |
|
| 201 | + * or gigabytes. For example, the value "10KB" will be interpreted |
|
| 202 | + * as 10240. |
|
| 203 | + * |
|
| 204 | + * @param mixed $value |
|
| 205 | + */ |
|
| 206 | + public function setMaxFileSize($value) |
|
| 207 | + { |
|
| 208 | + $maxFileSize = null; |
|
| 209 | + $numpart = substr($value,0, strlen($value) -2); |
|
| 210 | + $suffix = strtoupper(substr($value, -2)); |
|
| 211 | 211 | |
| 212 | - switch ($suffix) { |
|
| 213 | - case 'KB': $maxFileSize = (int)((int)$numpart * 1024); break; |
|
| 214 | - case 'MB': $maxFileSize = (int)((int)$numpart * 1024 * 1024); break; |
|
| 215 | - case 'GB': $maxFileSize = (int)((int)$numpart * 1024 * 1024 * 1024); break; |
|
| 216 | - default: |
|
| 217 | - if (is_numeric($value)) { |
|
| 218 | - $maxFileSize = (int)$value; |
|
| 219 | - } |
|
| 220 | - } |
|
| 212 | + switch ($suffix) { |
|
| 213 | + case 'KB': $maxFileSize = (int)((int)$numpart * 1024); break; |
|
| 214 | + case 'MB': $maxFileSize = (int)((int)$numpart * 1024 * 1024); break; |
|
| 215 | + case 'GB': $maxFileSize = (int)((int)$numpart * 1024 * 1024 * 1024); break; |
|
| 216 | + default: |
|
| 217 | + if (is_numeric($value)) { |
|
| 218 | + $maxFileSize = (int)$value; |
|
| 219 | + } |
|
| 220 | + } |
|
| 221 | 221 | |
| 222 | - if ($maxFileSize === null) { |
|
| 223 | - LoggerLog::debug("LoggerAppenderRollingFile::setMaxFileSize():value=[$value] wrong declaration"); |
|
| 224 | - } else { |
|
| 225 | - $this->maxFileSize = abs($maxFileSize); |
|
| 226 | - } |
|
| 227 | - } |
|
| 222 | + if ($maxFileSize === null) { |
|
| 223 | + LoggerLog::debug("LoggerAppenderRollingFile::setMaxFileSize():value=[$value] wrong declaration"); |
|
| 224 | + } else { |
|
| 225 | + $this->maxFileSize = abs($maxFileSize); |
|
| 226 | + } |
|
| 227 | + } |
|
| 228 | 228 | |
| 229 | - /** |
|
| 230 | - * @param LoggerLoggingEvent $event |
|
| 231 | - */ |
|
| 232 | - public function append($event) |
|
| 233 | - { |
|
| 234 | - if ($this->fp) { |
|
| 235 | - parent::append($event); |
|
| 236 | - if (ftell($this->fp) > $this->getMaximumFileSize()) |
|
| 237 | - $this->rollOver(); |
|
| 238 | - } |
|
| 239 | - } |
|
| 229 | + /** |
|
| 230 | + * @param LoggerLoggingEvent $event |
|
| 231 | + */ |
|
| 232 | + public function append($event) |
|
| 233 | + { |
|
| 234 | + if ($this->fp) { |
|
| 235 | + parent::append($event); |
|
| 236 | + if (ftell($this->fp) > $this->getMaximumFileSize()) |
|
| 237 | + $this->rollOver(); |
|
| 238 | + } |
|
| 239 | + } |
|
| 240 | 240 | } |
| 241 | 241 | ?> |
@@ -69,7 +69,7 @@ discard block |
||
| 69 | 69 | * |
| 70 | 70 | * @var integer |
| 71 | 71 | */ |
| 72 | - public $maxBackupIndex = 1; |
|
| 72 | + public $maxBackupIndex = 1; |
|
| 73 | 73 | |
| 74 | 74 | /** |
| 75 | 75 | * @var string the filename expanded |
@@ -123,7 +123,7 @@ discard block |
||
| 123 | 123 | public function rollOver() |
| 124 | 124 | { |
| 125 | 125 | // If maxBackups <= 0, then there is no file renaming to be done. |
| 126 | - if($this->maxBackupIndex > 0) { |
|
| 126 | + if ($this->maxBackupIndex > 0) { |
|
| 127 | 127 | $fileName = $this->getExpandedFileName(); |
| 128 | 128 | // Delete the oldest file, to keep Windows happy. |
| 129 | 129 | $file = $fileName . '.' . $this->maxBackupIndex; |
@@ -176,7 +176,7 @@ discard block |
||
| 176 | 176 | public function setMaxBackupIndex($maxBackups) |
| 177 | 177 | { |
| 178 | 178 | if (is_numeric($maxBackups)) |
| 179 | - $this->maxBackupIndex = abs((int)$maxBackups); |
|
| 179 | + $this->maxBackupIndex = abs((int) $maxBackups); |
|
| 180 | 180 | } |
| 181 | 181 | |
| 182 | 182 | /** |
@@ -206,16 +206,16 @@ discard block |
||
| 206 | 206 | public function setMaxFileSize($value) |
| 207 | 207 | { |
| 208 | 208 | $maxFileSize = null; |
| 209 | - $numpart = substr($value,0, strlen($value) -2); |
|
| 209 | + $numpart = substr($value, 0, strlen($value) - 2); |
|
| 210 | 210 | $suffix = strtoupper(substr($value, -2)); |
| 211 | 211 | |
| 212 | 212 | switch ($suffix) { |
| 213 | - case 'KB': $maxFileSize = (int)((int)$numpart * 1024); break; |
|
| 214 | - case 'MB': $maxFileSize = (int)((int)$numpart * 1024 * 1024); break; |
|
| 215 | - case 'GB': $maxFileSize = (int)((int)$numpart * 1024 * 1024 * 1024); break; |
|
| 213 | + case 'KB': $maxFileSize = (int) ((int) $numpart * 1024); break; |
|
| 214 | + case 'MB': $maxFileSize = (int) ((int) $numpart * 1024 * 1024); break; |
|
| 215 | + case 'GB': $maxFileSize = (int) ((int) $numpart * 1024 * 1024 * 1024); break; |
|
| 216 | 216 | default: |
| 217 | 217 | if (is_numeric($value)) { |
| 218 | - $maxFileSize = (int)$value; |
|
| 218 | + $maxFileSize = (int) $value; |
|
| 219 | 219 | } |
| 220 | 220 | } |
| 221 | 221 | |
@@ -43,243 +43,243 @@ |
||
| 43 | 43 | */ |
| 44 | 44 | class LoggerAppenderSocket extends LoggerAppenderSkeleton { |
| 45 | 45 | |
| 46 | - /** |
|
| 47 | - * @var mixed socket connection resource |
|
| 48 | - * @access private |
|
| 49 | - */ |
|
| 50 | - public $sp = false; |
|
| 46 | + /** |
|
| 47 | + * @var mixed socket connection resource |
|
| 48 | + * @access private |
|
| 49 | + */ |
|
| 50 | + public $sp = false; |
|
| 51 | 51 | |
| 52 | - /** |
|
| 53 | - * Target host. On how to define remote hostaname see |
|
| 54 | - * {@link PHP_MANUAL#fsockopen} |
|
| 55 | - * @var string |
|
| 56 | - */ |
|
| 57 | - public $remoteHost = ''; |
|
| 52 | + /** |
|
| 53 | + * Target host. On how to define remote hostaname see |
|
| 54 | + * {@link PHP_MANUAL#fsockopen} |
|
| 55 | + * @var string |
|
| 56 | + */ |
|
| 57 | + public $remoteHost = ''; |
|
| 58 | 58 | |
| 59 | - /** |
|
| 60 | - * @var integer the network port. |
|
| 61 | - */ |
|
| 62 | - public $port = LOG4PHP_LOGGER_APPENDER_SOCKET_DEFAULT_PORT; |
|
| 59 | + /** |
|
| 60 | + * @var integer the network port. |
|
| 61 | + */ |
|
| 62 | + public $port = LOG4PHP_LOGGER_APPENDER_SOCKET_DEFAULT_PORT; |
|
| 63 | 63 | |
| 64 | - /** |
|
| 65 | - * @var boolean get event's location info. |
|
| 66 | - */ |
|
| 67 | - public $locationInfo = false; |
|
| 64 | + /** |
|
| 65 | + * @var boolean get event's location info. |
|
| 66 | + */ |
|
| 67 | + public $locationInfo = false; |
|
| 68 | 68 | |
| 69 | - /** |
|
| 70 | - * @var integer connection timeout |
|
| 71 | - */ |
|
| 72 | - public $timeout = LOG4PHP_LOGGER_APPENDER_SOCKET_DEFAULT_TIMEOUT; |
|
| 69 | + /** |
|
| 70 | + * @var integer connection timeout |
|
| 71 | + */ |
|
| 72 | + public $timeout = LOG4PHP_LOGGER_APPENDER_SOCKET_DEFAULT_TIMEOUT; |
|
| 73 | 73 | |
| 74 | - /** |
|
| 75 | - * @var boolean output events via {@link LoggerXmlLayout} |
|
| 76 | - */ |
|
| 77 | - public $useXml = false; |
|
| 74 | + /** |
|
| 75 | + * @var boolean output events via {@link LoggerXmlLayout} |
|
| 76 | + */ |
|
| 77 | + public $useXml = false; |
|
| 78 | 78 | |
| 79 | - /** |
|
| 80 | - * @var boolean forward this option to {@link LoggerXmlLayout}. |
|
| 81 | - * Ignored if {@link $useXml} is <i>false</i>. |
|
| 82 | - */ |
|
| 83 | - public $log4jNamespace = false; |
|
| 79 | + /** |
|
| 80 | + * @var boolean forward this option to {@link LoggerXmlLayout}. |
|
| 81 | + * Ignored if {@link $useXml} is <i>false</i>. |
|
| 82 | + */ |
|
| 83 | + public $log4jNamespace = false; |
|
| 84 | 84 | |
| 85 | - /** |
|
| 86 | - * @var LoggerXmlLayout |
|
| 87 | - * @access private |
|
| 88 | - */ |
|
| 89 | - public $xmlLayout = null; |
|
| 85 | + /** |
|
| 86 | + * @var LoggerXmlLayout |
|
| 87 | + * @access private |
|
| 88 | + */ |
|
| 89 | + public $xmlLayout = null; |
|
| 90 | 90 | |
| 91 | - /** |
|
| 92 | - * @var boolean |
|
| 93 | - * @access private |
|
| 94 | - */ |
|
| 95 | - public $requiresLayout = false; |
|
| 91 | + /** |
|
| 92 | + * @var boolean |
|
| 93 | + * @access private |
|
| 94 | + */ |
|
| 95 | + public $requiresLayout = false; |
|
| 96 | 96 | |
| 97 | - /** |
|
| 98 | - * Constructor |
|
| 99 | - * |
|
| 100 | - * @param string $name appender name |
|
| 101 | - */ |
|
| 102 | - public function LoggerAppenderSocket($name) |
|
| 103 | - { |
|
| 104 | - $this->LoggerAppenderSkeleton($name); |
|
| 105 | - } |
|
| 97 | + /** |
|
| 98 | + * Constructor |
|
| 99 | + * |
|
| 100 | + * @param string $name appender name |
|
| 101 | + */ |
|
| 102 | + public function LoggerAppenderSocket($name) |
|
| 103 | + { |
|
| 104 | + $this->LoggerAppenderSkeleton($name); |
|
| 105 | + } |
|
| 106 | 106 | |
| 107 | - /** |
|
| 108 | - * Create a socket connection using defined parameters |
|
| 109 | - */ |
|
| 110 | - public function activateOptions() |
|
| 111 | - { |
|
| 112 | - LoggerLog::debug("LoggerAppenderSocket::activateOptions() creating a socket..."); |
|
| 113 | - $errno = 0; |
|
| 114 | - $errstr = ''; |
|
| 115 | - $this->sp = @fsockopen($this->getRemoteHost(), $this->getPort(), $errno, $errstr, $this->getTimeout()); |
|
| 116 | - if ($errno) { |
|
| 117 | - LoggerLog::debug("LoggerAppenderSocket::activateOptions() socket error [$errno] $errstr"); |
|
| 118 | - $this->closed = true; |
|
| 119 | - } else { |
|
| 120 | - LoggerLog::debug("LoggerAppenderSocket::activateOptions() socket created [".$this->sp."]"); |
|
| 121 | - if ($this->getUseXml()) { |
|
| 122 | - $this->xmlLayout = LoggerLayout::factory('LoggerXmlLayout'); |
|
| 123 | - if ($this->xmlLayout === null) { |
|
| 124 | - LoggerLog::debug("LoggerAppenderSocket::activateOptions() useXml is true but layout is null"); |
|
| 125 | - $this->setUseXml(false); |
|
| 126 | - } else { |
|
| 127 | - $this->xmlLayout->setLocationInfo($this->getLocationInfo()); |
|
| 128 | - $this->xmlLayout->setLog4jNamespace($this->getLog4jNamespace()); |
|
| 129 | - $this->xmlLayout->activateOptions(); |
|
| 130 | - } |
|
| 131 | - } |
|
| 132 | - $this->closed = false; |
|
| 133 | - } |
|
| 134 | - } |
|
| 107 | + /** |
|
| 108 | + * Create a socket connection using defined parameters |
|
| 109 | + */ |
|
| 110 | + public function activateOptions() |
|
| 111 | + { |
|
| 112 | + LoggerLog::debug("LoggerAppenderSocket::activateOptions() creating a socket..."); |
|
| 113 | + $errno = 0; |
|
| 114 | + $errstr = ''; |
|
| 115 | + $this->sp = @fsockopen($this->getRemoteHost(), $this->getPort(), $errno, $errstr, $this->getTimeout()); |
|
| 116 | + if ($errno) { |
|
| 117 | + LoggerLog::debug("LoggerAppenderSocket::activateOptions() socket error [$errno] $errstr"); |
|
| 118 | + $this->closed = true; |
|
| 119 | + } else { |
|
| 120 | + LoggerLog::debug("LoggerAppenderSocket::activateOptions() socket created [".$this->sp."]"); |
|
| 121 | + if ($this->getUseXml()) { |
|
| 122 | + $this->xmlLayout = LoggerLayout::factory('LoggerXmlLayout'); |
|
| 123 | + if ($this->xmlLayout === null) { |
|
| 124 | + LoggerLog::debug("LoggerAppenderSocket::activateOptions() useXml is true but layout is null"); |
|
| 125 | + $this->setUseXml(false); |
|
| 126 | + } else { |
|
| 127 | + $this->xmlLayout->setLocationInfo($this->getLocationInfo()); |
|
| 128 | + $this->xmlLayout->setLog4jNamespace($this->getLog4jNamespace()); |
|
| 129 | + $this->xmlLayout->activateOptions(); |
|
| 130 | + } |
|
| 131 | + } |
|
| 132 | + $this->closed = false; |
|
| 133 | + } |
|
| 134 | + } |
|
| 135 | 135 | |
| 136 | - public function close() |
|
| 137 | - { |
|
| 138 | - @fclose($this->sp); |
|
| 139 | - $this->closed = true; |
|
| 140 | - } |
|
| 136 | + public function close() |
|
| 137 | + { |
|
| 138 | + @fclose($this->sp); |
|
| 139 | + $this->closed = true; |
|
| 140 | + } |
|
| 141 | 141 | |
| 142 | - /** |
|
| 143 | - * @return string |
|
| 144 | - */ |
|
| 145 | - public function getHostname() |
|
| 146 | - { |
|
| 147 | - return $this->getRemoteHost(); |
|
| 148 | - } |
|
| 142 | + /** |
|
| 143 | + * @return string |
|
| 144 | + */ |
|
| 145 | + public function getHostname() |
|
| 146 | + { |
|
| 147 | + return $this->getRemoteHost(); |
|
| 148 | + } |
|
| 149 | 149 | |
| 150 | - /** |
|
| 151 | - * @return boolean |
|
| 152 | - */ |
|
| 153 | - public function getLocationInfo() |
|
| 154 | - { |
|
| 155 | - return $this->locationInfo; |
|
| 156 | - } |
|
| 150 | + /** |
|
| 151 | + * @return boolean |
|
| 152 | + */ |
|
| 153 | + public function getLocationInfo() |
|
| 154 | + { |
|
| 155 | + return $this->locationInfo; |
|
| 156 | + } |
|
| 157 | 157 | |
| 158 | - /** |
|
| 159 | - * @return boolean |
|
| 160 | - */ |
|
| 161 | - public function getLog4jNamespace() |
|
| 162 | - { |
|
| 163 | - return $this->log4jNamespace; |
|
| 164 | - } |
|
| 158 | + /** |
|
| 159 | + * @return boolean |
|
| 160 | + */ |
|
| 161 | + public function getLog4jNamespace() |
|
| 162 | + { |
|
| 163 | + return $this->log4jNamespace; |
|
| 164 | + } |
|
| 165 | 165 | |
| 166 | - /** |
|
| 167 | - * @return integer |
|
| 168 | - */ |
|
| 169 | - public function getPort() |
|
| 170 | - { |
|
| 171 | - return $this->port; |
|
| 172 | - } |
|
| 166 | + /** |
|
| 167 | + * @return integer |
|
| 168 | + */ |
|
| 169 | + public function getPort() |
|
| 170 | + { |
|
| 171 | + return $this->port; |
|
| 172 | + } |
|
| 173 | 173 | |
| 174 | - public function getRemoteHost() |
|
| 175 | - { |
|
| 176 | - return $this->remoteHost; |
|
| 177 | - } |
|
| 174 | + public function getRemoteHost() |
|
| 175 | + { |
|
| 176 | + return $this->remoteHost; |
|
| 177 | + } |
|
| 178 | 178 | |
| 179 | - /** |
|
| 180 | - * @return integer |
|
| 181 | - */ |
|
| 182 | - public function getTimeout() |
|
| 183 | - { |
|
| 184 | - return $this->timeout; |
|
| 185 | - } |
|
| 179 | + /** |
|
| 180 | + * @return integer |
|
| 181 | + */ |
|
| 182 | + public function getTimeout() |
|
| 183 | + { |
|
| 184 | + return $this->timeout; |
|
| 185 | + } |
|
| 186 | 186 | |
| 187 | - /** |
|
| 188 | - * @var boolean |
|
| 189 | - */ |
|
| 190 | - public function getUseXml() |
|
| 191 | - { |
|
| 192 | - return $this->useXml; |
|
| 193 | - } |
|
| 187 | + /** |
|
| 188 | + * @var boolean |
|
| 189 | + */ |
|
| 190 | + public function getUseXml() |
|
| 191 | + { |
|
| 192 | + return $this->useXml; |
|
| 193 | + } |
|
| 194 | 194 | |
| 195 | - public function reset() |
|
| 196 | - { |
|
| 197 | - $this->close(); |
|
| 198 | - parent::reset(); |
|
| 199 | - } |
|
| 195 | + public function reset() |
|
| 196 | + { |
|
| 197 | + $this->close(); |
|
| 198 | + parent::reset(); |
|
| 199 | + } |
|
| 200 | 200 | |
| 201 | - /** |
|
| 202 | - * @param string |
|
| 203 | - * @deprecated Please, use {@link setRemoteHost} |
|
| 204 | - */ |
|
| 205 | - public function setHostname($hostname) |
|
| 206 | - { |
|
| 207 | - $this->setRemoteHost($hostname); |
|
| 208 | - } |
|
| 201 | + /** |
|
| 202 | + * @param string |
|
| 203 | + * @deprecated Please, use {@link setRemoteHost} |
|
| 204 | + */ |
|
| 205 | + public function setHostname($hostname) |
|
| 206 | + { |
|
| 207 | + $this->setRemoteHost($hostname); |
|
| 208 | + } |
|
| 209 | 209 | |
| 210 | - /** |
|
| 211 | - * @param mixed |
|
| 212 | - */ |
|
| 213 | - public function setLocationInfo($flag) |
|
| 214 | - { |
|
| 215 | - $this->locationInfo = LoggerOptionConverter::toBoolean($flag, $this->getLocationInfo()); |
|
| 216 | - } |
|
| 210 | + /** |
|
| 211 | + * @param mixed |
|
| 212 | + */ |
|
| 213 | + public function setLocationInfo($flag) |
|
| 214 | + { |
|
| 215 | + $this->locationInfo = LoggerOptionConverter::toBoolean($flag, $this->getLocationInfo()); |
|
| 216 | + } |
|
| 217 | 217 | |
| 218 | - /** |
|
| 219 | - * @param mixed |
|
| 220 | - */ |
|
| 221 | - public function setLog4jNamespace($flag) |
|
| 222 | - { |
|
| 223 | - $this->log4jNamespace = LoggerOptionConverter::toBoolean($flag, $this->getLog4jNamespace()); |
|
| 224 | - } |
|
| 218 | + /** |
|
| 219 | + * @param mixed |
|
| 220 | + */ |
|
| 221 | + public function setLog4jNamespace($flag) |
|
| 222 | + { |
|
| 223 | + $this->log4jNamespace = LoggerOptionConverter::toBoolean($flag, $this->getLog4jNamespace()); |
|
| 224 | + } |
|
| 225 | 225 | |
| 226 | - /** |
|
| 227 | - * @param integer |
|
| 228 | - */ |
|
| 229 | - public function setPort($port) |
|
| 230 | - { |
|
| 231 | - $port = LoggerOptionConverter::toInt($port, 0); |
|
| 232 | - if ($port > 0 && $port < 65535) |
|
| 233 | - $this->port = $port; |
|
| 234 | - } |
|
| 226 | + /** |
|
| 227 | + * @param integer |
|
| 228 | + */ |
|
| 229 | + public function setPort($port) |
|
| 230 | + { |
|
| 231 | + $port = LoggerOptionConverter::toInt($port, 0); |
|
| 232 | + if ($port > 0 && $port < 65535) |
|
| 233 | + $this->port = $port; |
|
| 234 | + } |
|
| 235 | 235 | |
| 236 | - /** |
|
| 237 | - * @param string |
|
| 238 | - */ |
|
| 239 | - public function setRemoteHost($hostname) |
|
| 240 | - { |
|
| 241 | - $this->remoteHost = $hostname; |
|
| 242 | - } |
|
| 236 | + /** |
|
| 237 | + * @param string |
|
| 238 | + */ |
|
| 239 | + public function setRemoteHost($hostname) |
|
| 240 | + { |
|
| 241 | + $this->remoteHost = $hostname; |
|
| 242 | + } |
|
| 243 | 243 | |
| 244 | - /** |
|
| 245 | - * @param integer |
|
| 246 | - */ |
|
| 247 | - public function setTimeout($timeout) |
|
| 248 | - { |
|
| 249 | - $this->timeout = LoggerOptionConverter::toInt($timeout, $this->getTimeout()); |
|
| 250 | - } |
|
| 244 | + /** |
|
| 245 | + * @param integer |
|
| 246 | + */ |
|
| 247 | + public function setTimeout($timeout) |
|
| 248 | + { |
|
| 249 | + $this->timeout = LoggerOptionConverter::toInt($timeout, $this->getTimeout()); |
|
| 250 | + } |
|
| 251 | 251 | |
| 252 | - /** |
|
| 253 | - * @param mixed |
|
| 254 | - */ |
|
| 255 | - public function setUseXml($flag) |
|
| 256 | - { |
|
| 257 | - $this->useXml = LoggerOptionConverter::toBoolean($flag, $this->getUseXml()); |
|
| 258 | - } |
|
| 252 | + /** |
|
| 253 | + * @param mixed |
|
| 254 | + */ |
|
| 255 | + public function setUseXml($flag) |
|
| 256 | + { |
|
| 257 | + $this->useXml = LoggerOptionConverter::toBoolean($flag, $this->getUseXml()); |
|
| 258 | + } |
|
| 259 | 259 | |
| 260 | - /** |
|
| 261 | - * @param LoggerLoggingEvent |
|
| 262 | - */ |
|
| 263 | - public function append($event) |
|
| 264 | - { |
|
| 265 | - if ($this->sp) { |
|
| 260 | + /** |
|
| 261 | + * @param LoggerLoggingEvent |
|
| 262 | + */ |
|
| 263 | + public function append($event) |
|
| 264 | + { |
|
| 265 | + if ($this->sp) { |
|
| 266 | 266 | |
| 267 | - LoggerLog::debug("LoggerAppenderSocket::append()"); |
|
| 267 | + LoggerLog::debug("LoggerAppenderSocket::append()"); |
|
| 268 | 268 | |
| 269 | - if ($this->getLocationInfo()) |
|
| 270 | - $event->getLocationInfo(); |
|
| 269 | + if ($this->getLocationInfo()) |
|
| 270 | + $event->getLocationInfo(); |
|
| 271 | 271 | |
| 272 | - if (!$this->getUseXml()) { |
|
| 273 | - $sEvent = serialize($event); |
|
| 274 | - @fwrite($this->sp, $sEvent, strlen($sEvent)); |
|
| 275 | - } else { |
|
| 276 | - @fwrite($this->sp, $this->xmlLayout->format($event)); |
|
| 277 | - } |
|
| 272 | + if (!$this->getUseXml()) { |
|
| 273 | + $sEvent = serialize($event); |
|
| 274 | + @fwrite($this->sp, $sEvent, strlen($sEvent)); |
|
| 275 | + } else { |
|
| 276 | + @fwrite($this->sp, $this->xmlLayout->format($event)); |
|
| 277 | + } |
|
| 278 | 278 | |
| 279 | - // not sure about it... |
|
| 280 | - @fflush ($this->sp); |
|
| 281 | - } |
|
| 282 | - } |
|
| 279 | + // not sure about it... |
|
| 280 | + @fflush ($this->sp); |
|
| 281 | + } |
|
| 282 | + } |
|
| 283 | 283 | } |
| 284 | 284 | |
| 285 | 285 | ?> |
| 286 | 286 | \ No newline at end of file |
@@ -22,8 +22,8 @@ discard block |
||
| 22 | 22 | */ |
| 23 | 23 | if (!defined('LOG4PHP_DIR')) define('LOG4PHP_DIR', dirname(__FILE__) . '/..'); |
| 24 | 24 | |
| 25 | -define('LOG4PHP_LOGGER_APPENDER_SOCKET_DEFAULT_PORT', 4446); |
|
| 26 | -define('LOG4PHP_LOGGER_APPENDER_SOCKET_DEFAULT_TIMEOUT', 30); |
|
| 25 | +define('LOG4PHP_LOGGER_APPENDER_SOCKET_DEFAULT_PORT', 4446); |
|
| 26 | +define('LOG4PHP_LOGGER_APPENDER_SOCKET_DEFAULT_TIMEOUT', 30); |
|
| 27 | 27 | |
| 28 | 28 | require_once(LOG4PHP_DIR . '/LoggerAppenderSkeleton.php'); |
| 29 | 29 | require_once(LOG4PHP_DIR . '/helpers/LoggerOptionConverter.php'); |
@@ -54,27 +54,27 @@ discard block |
||
| 54 | 54 | * {@link PHP_MANUAL#fsockopen} |
| 55 | 55 | * @var string |
| 56 | 56 | */ |
| 57 | - public $remoteHost = ''; |
|
| 57 | + public $remoteHost = ''; |
|
| 58 | 58 | |
| 59 | 59 | /** |
| 60 | 60 | * @var integer the network port. |
| 61 | 61 | */ |
| 62 | - public $port = LOG4PHP_LOGGER_APPENDER_SOCKET_DEFAULT_PORT; |
|
| 62 | + public $port = LOG4PHP_LOGGER_APPENDER_SOCKET_DEFAULT_PORT; |
|
| 63 | 63 | |
| 64 | 64 | /** |
| 65 | 65 | * @var boolean get event's location info. |
| 66 | 66 | */ |
| 67 | - public $locationInfo = false; |
|
| 67 | + public $locationInfo = false; |
|
| 68 | 68 | |
| 69 | 69 | /** |
| 70 | 70 | * @var integer connection timeout |
| 71 | 71 | */ |
| 72 | - public $timeout = LOG4PHP_LOGGER_APPENDER_SOCKET_DEFAULT_TIMEOUT; |
|
| 72 | + public $timeout = LOG4PHP_LOGGER_APPENDER_SOCKET_DEFAULT_TIMEOUT; |
|
| 73 | 73 | |
| 74 | 74 | /** |
| 75 | 75 | * @var boolean output events via {@link LoggerXmlLayout} |
| 76 | 76 | */ |
| 77 | - public $useXml = false; |
|
| 77 | + public $useXml = false; |
|
| 78 | 78 | |
| 79 | 79 | /** |
| 80 | 80 | * @var boolean forward this option to {@link LoggerXmlLayout}. |
@@ -86,7 +86,7 @@ discard block |
||
| 86 | 86 | * @var LoggerXmlLayout |
| 87 | 87 | * @access private |
| 88 | 88 | */ |
| 89 | - public $xmlLayout = null; |
|
| 89 | + public $xmlLayout = null; |
|
| 90 | 90 | |
| 91 | 91 | /** |
| 92 | 92 | * @var boolean |
@@ -117,7 +117,7 @@ discard block |
||
| 117 | 117 | LoggerLog::debug("LoggerAppenderSocket::activateOptions() socket error [$errno] $errstr"); |
| 118 | 118 | $this->closed = true; |
| 119 | 119 | } else { |
| 120 | - LoggerLog::debug("LoggerAppenderSocket::activateOptions() socket created [".$this->sp."]"); |
|
| 120 | + LoggerLog::debug("LoggerAppenderSocket::activateOptions() socket created [" . $this->sp . "]"); |
|
| 121 | 121 | if ($this->getUseXml()) { |
| 122 | 122 | $this->xmlLayout = LoggerLayout::factory('LoggerXmlLayout'); |
| 123 | 123 | if ($this->xmlLayout === null) { |
@@ -277,7 +277,7 @@ discard block |
||
| 277 | 277 | } |
| 278 | 278 | |
| 279 | 279 | // not sure about it... |
| 280 | - @fflush ($this->sp); |
|
| 280 | + @fflush($this->sp); |
|
| 281 | 281 | } |
| 282 | 282 | } |
| 283 | 283 | } |
@@ -42,167 +42,167 @@ |
||
| 42 | 42 | */ |
| 43 | 43 | class LoggerAppenderDb extends LoggerAppenderSkeleton { |
| 44 | 44 | |
| 45 | - /** |
|
| 46 | - * Create the log table if it does not exists (optional). |
|
| 47 | - * @var boolean |
|
| 48 | - */ |
|
| 49 | - public $createTable = true; |
|
| 50 | - |
|
| 51 | - /** |
|
| 52 | - * PEAR::Db Data source name. Read PEAR::Db for dsn syntax (mandatory). |
|
| 53 | - * @var string |
|
| 54 | - */ |
|
| 55 | - public $dsn; |
|
| 56 | - |
|
| 57 | - /** |
|
| 58 | - * A {@link LoggerPatternLayout} string used to format a valid insert query (mandatory). |
|
| 59 | - * @var string |
|
| 60 | - */ |
|
| 61 | - public $sql; |
|
| 62 | - |
|
| 63 | - /** |
|
| 64 | - * Table name to write events. Used only if {@link $createTable} is true. |
|
| 65 | - * @var string |
|
| 66 | - */ |
|
| 67 | - public $table; |
|
| 68 | - |
|
| 69 | - /** |
|
| 70 | - * @var object PEAR::Db instance |
|
| 71 | - * @access private |
|
| 72 | - */ |
|
| 73 | - public $db = null; |
|
| 74 | - |
|
| 75 | - /** |
|
| 76 | - * @var boolean used to check if all conditions to append are true |
|
| 77 | - * @access private |
|
| 78 | - */ |
|
| 79 | - public $canAppend = true; |
|
| 80 | - |
|
| 81 | - /** |
|
| 82 | - * @access private |
|
| 83 | - */ |
|
| 84 | - public $requiresLayout = false; |
|
| 85 | - |
|
| 86 | - /** |
|
| 87 | - * Constructor. |
|
| 88 | - * |
|
| 89 | - * @param string $name appender name |
|
| 90 | - */ |
|
| 91 | - public function LoggerAppenderDb($name) |
|
| 92 | - { |
|
| 93 | - $this->LoggerAppenderSkeleton($name); |
|
| 94 | - } |
|
| 45 | + /** |
|
| 46 | + * Create the log table if it does not exists (optional). |
|
| 47 | + * @var boolean |
|
| 48 | + */ |
|
| 49 | + public $createTable = true; |
|
| 50 | + |
|
| 51 | + /** |
|
| 52 | + * PEAR::Db Data source name. Read PEAR::Db for dsn syntax (mandatory). |
|
| 53 | + * @var string |
|
| 54 | + */ |
|
| 55 | + public $dsn; |
|
| 56 | + |
|
| 57 | + /** |
|
| 58 | + * A {@link LoggerPatternLayout} string used to format a valid insert query (mandatory). |
|
| 59 | + * @var string |
|
| 60 | + */ |
|
| 61 | + public $sql; |
|
| 62 | + |
|
| 63 | + /** |
|
| 64 | + * Table name to write events. Used only if {@link $createTable} is true. |
|
| 65 | + * @var string |
|
| 66 | + */ |
|
| 67 | + public $table; |
|
| 68 | + |
|
| 69 | + /** |
|
| 70 | + * @var object PEAR::Db instance |
|
| 71 | + * @access private |
|
| 72 | + */ |
|
| 73 | + public $db = null; |
|
| 74 | + |
|
| 75 | + /** |
|
| 76 | + * @var boolean used to check if all conditions to append are true |
|
| 77 | + * @access private |
|
| 78 | + */ |
|
| 79 | + public $canAppend = true; |
|
| 80 | + |
|
| 81 | + /** |
|
| 82 | + * @access private |
|
| 83 | + */ |
|
| 84 | + public $requiresLayout = false; |
|
| 85 | + |
|
| 86 | + /** |
|
| 87 | + * Constructor. |
|
| 88 | + * |
|
| 89 | + * @param string $name appender name |
|
| 90 | + */ |
|
| 91 | + public function LoggerAppenderDb($name) |
|
| 92 | + { |
|
| 93 | + $this->LoggerAppenderSkeleton($name); |
|
| 94 | + } |
|
| 95 | 95 | |
| 96 | - /** |
|
| 97 | - * Setup db connection. |
|
| 98 | - * Based on defined options, this method connects to db defined in {@link $dsn} |
|
| 99 | - * and creates a {@link $table} table if {@link $createTable} is true. |
|
| 100 | - * @return boolean true if all ok. |
|
| 101 | - */ |
|
| 102 | - public function activateOptions() |
|
| 103 | - { |
|
| 104 | - $this->db = DB::connect($this->dsn); |
|
| 96 | + /** |
|
| 97 | + * Setup db connection. |
|
| 98 | + * Based on defined options, this method connects to db defined in {@link $dsn} |
|
| 99 | + * and creates a {@link $table} table if {@link $createTable} is true. |
|
| 100 | + * @return boolean true if all ok. |
|
| 101 | + */ |
|
| 102 | + public function activateOptions() |
|
| 103 | + { |
|
| 104 | + $this->db = DB::connect($this->dsn); |
|
| 105 | 105 | |
| 106 | - if (DB::isError($this->db)) { |
|
| 107 | - LoggerLog::debug("LoggerAppenderDb::activateOptions() DB Connect Error [".$this->db->getMessage()."]"); |
|
| 108 | - $this->db = null; |
|
| 109 | - $this->closed = true; |
|
| 110 | - $this->canAppend = false; |
|
| 106 | + if (DB::isError($this->db)) { |
|
| 107 | + LoggerLog::debug("LoggerAppenderDb::activateOptions() DB Connect Error [".$this->db->getMessage()."]"); |
|
| 108 | + $this->db = null; |
|
| 109 | + $this->closed = true; |
|
| 110 | + $this->canAppend = false; |
|
| 111 | 111 | |
| 112 | - } else { |
|
| 112 | + } else { |
|
| 113 | 113 | |
| 114 | - $this->layout = LoggerLayout::factory('LoggerPatternLayout'); |
|
| 115 | - $this->layout->setConversionPattern($this->getSql()); |
|
| 114 | + $this->layout = LoggerLayout::factory('LoggerPatternLayout'); |
|
| 115 | + $this->layout->setConversionPattern($this->getSql()); |
|
| 116 | 116 | |
| 117 | - // test if log table exists |
|
| 118 | - $tableInfo = $this->db->tableInfo($this->table, $mode = null); |
|
| 119 | - if (DB::isError($tableInfo) && $this->getCreateTable()) { |
|
| 120 | - $query = "CREATE TABLE {$this->table} (timestamp varchar(32),logger varchar(32),level varchar(32),message varchar(64),thread varchar(32),file varchar(64),line varchar(4) );"; |
|
| 117 | + // test if log table exists |
|
| 118 | + $tableInfo = $this->db->tableInfo($this->table, $mode = null); |
|
| 119 | + if (DB::isError($tableInfo) && $this->getCreateTable()) { |
|
| 120 | + $query = "CREATE TABLE {$this->table} (timestamp varchar(32),logger varchar(32),level varchar(32),message varchar(64),thread varchar(32),file varchar(64),line varchar(4) );"; |
|
| 121 | 121 | |
| 122 | - LoggerLog::debug("LoggerAppenderDb::activateOptions() creating table '{$this->table}'... using sql='$query'"); |
|
| 122 | + LoggerLog::debug("LoggerAppenderDb::activateOptions() creating table '{$this->table}'... using sql='$query'"); |
|
| 123 | 123 | |
| 124 | - $result = $this->db->query($query); |
|
| 125 | - if (DB::isError($result)) { |
|
| 126 | - LoggerLog::debug("LoggerAppenderDb::activateOptions() error while creating '{$this->table}'. Error is ".$result->getMessage()); |
|
| 127 | - $this->canAppend = false; |
|
| 128 | - return; |
|
| 129 | - } |
|
| 130 | - } |
|
| 131 | - $this->canAppend = true; |
|
| 132 | - } |
|
| 124 | + $result = $this->db->query($query); |
|
| 125 | + if (DB::isError($result)) { |
|
| 126 | + LoggerLog::debug("LoggerAppenderDb::activateOptions() error while creating '{$this->table}'. Error is ".$result->getMessage()); |
|
| 127 | + $this->canAppend = false; |
|
| 128 | + return; |
|
| 129 | + } |
|
| 130 | + } |
|
| 131 | + $this->canAppend = true; |
|
| 132 | + } |
|
| 133 | 133 | |
| 134 | - } |
|
| 134 | + } |
|
| 135 | 135 | |
| 136 | - public function append($event) |
|
| 137 | - { |
|
| 138 | - if ($this->canAppend) { |
|
| 136 | + public function append($event) |
|
| 137 | + { |
|
| 138 | + if ($this->canAppend) { |
|
| 139 | 139 | |
| 140 | - $query = $this->layout->format($event); |
|
| 140 | + $query = $this->layout->format($event); |
|
| 141 | 141 | |
| 142 | - LoggerLog::debug("LoggerAppenderDb::append() query='$query'"); |
|
| 142 | + LoggerLog::debug("LoggerAppenderDb::append() query='$query'"); |
|
| 143 | 143 | |
| 144 | - $this->db->query($query); |
|
| 145 | - } |
|
| 146 | - } |
|
| 147 | - |
|
| 148 | - public function close() |
|
| 149 | - { |
|
| 150 | - if ($this->db !== null) |
|
| 151 | - $this->db->disconnect(); |
|
| 152 | - $this->closed = true; |
|
| 153 | - } |
|
| 154 | - |
|
| 155 | - /** |
|
| 156 | - * @return boolean |
|
| 157 | - */ |
|
| 158 | - public function getCreateTable() |
|
| 159 | - { |
|
| 160 | - return $this->createTable; |
|
| 161 | - } |
|
| 162 | - |
|
| 163 | - /** |
|
| 164 | - * @return string the defined dsn |
|
| 165 | - */ |
|
| 166 | - public function getDsn() |
|
| 167 | - { |
|
| 168 | - return $this->dsn; |
|
| 169 | - } |
|
| 170 | - |
|
| 171 | - /** |
|
| 172 | - * @return string the sql pattern string |
|
| 173 | - */ |
|
| 174 | - public function getSql() |
|
| 175 | - { |
|
| 176 | - return $this->sql; |
|
| 177 | - } |
|
| 178 | - |
|
| 179 | - /** |
|
| 180 | - * @return string the table name to create |
|
| 181 | - */ |
|
| 182 | - public function getTable() |
|
| 183 | - { |
|
| 184 | - return $this->table; |
|
| 185 | - } |
|
| 186 | - |
|
| 187 | - public function setCreateTable($flag) |
|
| 188 | - { |
|
| 189 | - $this->createTable = LoggerOptionConverter::toBoolean($flag, true); |
|
| 190 | - } |
|
| 191 | - |
|
| 192 | - public function setDsn($newDsn) |
|
| 193 | - { |
|
| 194 | - $this->dsn = $newDsn; |
|
| 195 | - } |
|
| 196 | - |
|
| 197 | - public function setSql($sql) |
|
| 198 | - { |
|
| 199 | - $this->sql = $sql; |
|
| 200 | - } |
|
| 201 | - |
|
| 202 | - public function setTable($table) |
|
| 203 | - { |
|
| 204 | - $this->table = $table; |
|
| 205 | - } |
|
| 144 | + $this->db->query($query); |
|
| 145 | + } |
|
| 146 | + } |
|
| 147 | + |
|
| 148 | + public function close() |
|
| 149 | + { |
|
| 150 | + if ($this->db !== null) |
|
| 151 | + $this->db->disconnect(); |
|
| 152 | + $this->closed = true; |
|
| 153 | + } |
|
| 154 | + |
|
| 155 | + /** |
|
| 156 | + * @return boolean |
|
| 157 | + */ |
|
| 158 | + public function getCreateTable() |
|
| 159 | + { |
|
| 160 | + return $this->createTable; |
|
| 161 | + } |
|
| 162 | + |
|
| 163 | + /** |
|
| 164 | + * @return string the defined dsn |
|
| 165 | + */ |
|
| 166 | + public function getDsn() |
|
| 167 | + { |
|
| 168 | + return $this->dsn; |
|
| 169 | + } |
|
| 170 | + |
|
| 171 | + /** |
|
| 172 | + * @return string the sql pattern string |
|
| 173 | + */ |
|
| 174 | + public function getSql() |
|
| 175 | + { |
|
| 176 | + return $this->sql; |
|
| 177 | + } |
|
| 178 | + |
|
| 179 | + /** |
|
| 180 | + * @return string the table name to create |
|
| 181 | + */ |
|
| 182 | + public function getTable() |
|
| 183 | + { |
|
| 184 | + return $this->table; |
|
| 185 | + } |
|
| 186 | + |
|
| 187 | + public function setCreateTable($flag) |
|
| 188 | + { |
|
| 189 | + $this->createTable = LoggerOptionConverter::toBoolean($flag, true); |
|
| 190 | + } |
|
| 191 | + |
|
| 192 | + public function setDsn($newDsn) |
|
| 193 | + { |
|
| 194 | + $this->dsn = $newDsn; |
|
| 195 | + } |
|
| 196 | + |
|
| 197 | + public function setSql($sql) |
|
| 198 | + { |
|
| 199 | + $this->sql = $sql; |
|
| 200 | + } |
|
| 201 | + |
|
| 202 | + public function setTable($table) |
|
| 203 | + { |
|
| 204 | + $this->table = $table; |
|
| 205 | + } |
|
| 206 | 206 | |
| 207 | 207 | } |
| 208 | 208 | |
@@ -41,45 +41,45 @@ |
||
| 41 | 41 | */ |
| 42 | 42 | class LoggerAppenderPhp extends LoggerAppenderSkeleton { |
| 43 | 43 | |
| 44 | - /** |
|
| 45 | - * @access private |
|
| 46 | - */ |
|
| 47 | - public $requiresLayout = false; |
|
| 44 | + /** |
|
| 45 | + * @access private |
|
| 46 | + */ |
|
| 47 | + public $requiresLayout = false; |
|
| 48 | 48 | |
| 49 | - /** |
|
| 50 | - * Constructor |
|
| 51 | - * |
|
| 52 | - * @param string $name appender name |
|
| 53 | - */ |
|
| 54 | - public function LoggerAppenderPhp($name) |
|
| 55 | - { |
|
| 56 | - $this->LoggerAppenderSkeleton($name); |
|
| 57 | - } |
|
| 49 | + /** |
|
| 50 | + * Constructor |
|
| 51 | + * |
|
| 52 | + * @param string $name appender name |
|
| 53 | + */ |
|
| 54 | + public function LoggerAppenderPhp($name) |
|
| 55 | + { |
|
| 56 | + $this->LoggerAppenderSkeleton($name); |
|
| 57 | + } |
|
| 58 | 58 | |
| 59 | - public function activateOptions() |
|
| 60 | - { |
|
| 61 | - $this->layout = LoggerLayout::factory('LoggerLayoutTTCC'); |
|
| 62 | - $this->closed = false; |
|
| 63 | - } |
|
| 59 | + public function activateOptions() |
|
| 60 | + { |
|
| 61 | + $this->layout = LoggerLayout::factory('LoggerLayoutTTCC'); |
|
| 62 | + $this->closed = false; |
|
| 63 | + } |
|
| 64 | 64 | |
| 65 | - public function close() |
|
| 66 | - { |
|
| 67 | - $this->closed = true; |
|
| 68 | - } |
|
| 65 | + public function close() |
|
| 66 | + { |
|
| 67 | + $this->closed = true; |
|
| 68 | + } |
|
| 69 | 69 | |
| 70 | - public function append($event) |
|
| 71 | - { |
|
| 72 | - if ($this->layout !== null) { |
|
| 73 | - LoggerLog::debug("LoggerAppenderPhp::append()"); |
|
| 74 | - $level = $event->getLevel(); |
|
| 75 | - if ($level->isGreaterOrEqual(LoggerLevel::getLevelError())) { |
|
| 76 | - trigger_error($this->layout->format($event), E_USER_ERROR); |
|
| 77 | - } elseif ($level->isGreaterOrEqual(LoggerLevel::getLevelWarn())) { |
|
| 78 | - trigger_error($this->layout->format($event), E_USER_WARNING); |
|
| 79 | - } else { |
|
| 80 | - trigger_error($this->layout->format($event), E_USER_NOTICE); |
|
| 81 | - } |
|
| 82 | - } |
|
| 83 | - } |
|
| 70 | + public function append($event) |
|
| 71 | + { |
|
| 72 | + if ($this->layout !== null) { |
|
| 73 | + LoggerLog::debug("LoggerAppenderPhp::append()"); |
|
| 74 | + $level = $event->getLevel(); |
|
| 75 | + if ($level->isGreaterOrEqual(LoggerLevel::getLevelError())) { |
|
| 76 | + trigger_error($this->layout->format($event), E_USER_ERROR); |
|
| 77 | + } elseif ($level->isGreaterOrEqual(LoggerLevel::getLevelWarn())) { |
|
| 78 | + trigger_error($this->layout->format($event), E_USER_WARNING); |
|
| 79 | + } else { |
|
| 80 | + trigger_error($this->layout->format($event), E_USER_NOTICE); |
|
| 81 | + } |
|
| 82 | + } |
|
| 83 | + } |
|
| 84 | 84 | } |
| 85 | 85 | ?> |
| 86 | 86 | \ No newline at end of file |