@@ -24,48 +24,48 @@ |
||
24 | 24 | */ |
25 | 25 | class LoggerBasicPatternConverter extends LoggerPatternConverter { |
26 | 26 | |
27 | - /** |
|
28 | - * @var integer |
|
29 | - */ |
|
30 | - private $type; |
|
27 | + /** |
|
28 | + * @var integer |
|
29 | + */ |
|
30 | + private $type; |
|
31 | 31 | |
32 | - /** |
|
33 | - * Constructor |
|
34 | - * |
|
35 | - * @param string $formattingInfo |
|
36 | - * @param integer $type |
|
37 | - */ |
|
38 | - public function __construct($formattingInfo, $type) { |
|
39 | - parent::__construct($formattingInfo); |
|
40 | - $this->type = $type; |
|
41 | - } |
|
32 | + /** |
|
33 | + * Constructor |
|
34 | + * |
|
35 | + * @param string $formattingInfo |
|
36 | + * @param integer $type |
|
37 | + */ |
|
38 | + public function __construct($formattingInfo, $type) { |
|
39 | + parent::__construct($formattingInfo); |
|
40 | + $this->type = $type; |
|
41 | + } |
|
42 | 42 | |
43 | - /** |
|
44 | - * @param LoggerLoggingEvent $event |
|
45 | - * @return string |
|
46 | - */ |
|
47 | - public function convert($event) { |
|
48 | - switch($this->type) { |
|
49 | - case LoggerPatternParser::RELATIVE_TIME_CONVERTER: |
|
50 | - $timeStamp = $event->getTimeStamp(); |
|
51 | - $startTime = LoggerLoggingEvent::getStartTime(); |
|
52 | - return (string)(int)($timeStamp * 1000 - $startTime * 1000); |
|
43 | + /** |
|
44 | + * @param LoggerLoggingEvent $event |
|
45 | + * @return string |
|
46 | + */ |
|
47 | + public function convert($event) { |
|
48 | + switch($this->type) { |
|
49 | + case LoggerPatternParser::RELATIVE_TIME_CONVERTER: |
|
50 | + $timeStamp = $event->getTimeStamp(); |
|
51 | + $startTime = LoggerLoggingEvent::getStartTime(); |
|
52 | + return (string)(int)($timeStamp * 1000 - $startTime * 1000); |
|
53 | 53 | |
54 | - case LoggerPatternParser::THREAD_CONVERTER: |
|
55 | - return $event->getThreadName(); |
|
54 | + case LoggerPatternParser::THREAD_CONVERTER: |
|
55 | + return $event->getThreadName(); |
|
56 | 56 | |
57 | - case LoggerPatternParser::LEVEL_CONVERTER: |
|
58 | - $level = $event->getLevel(); |
|
59 | - return $level->toString(); |
|
57 | + case LoggerPatternParser::LEVEL_CONVERTER: |
|
58 | + $level = $event->getLevel(); |
|
59 | + return $level->toString(); |
|
60 | 60 | |
61 | - case LoggerPatternParser::NDC_CONVERTER: |
|
62 | - return $event->getNDC(); |
|
61 | + case LoggerPatternParser::NDC_CONVERTER: |
|
62 | + return $event->getNDC(); |
|
63 | 63 | |
64 | - case LoggerPatternParser::MESSAGE_CONVERTER: |
|
65 | - return $event->getRenderedMessage(); |
|
64 | + case LoggerPatternParser::MESSAGE_CONVERTER: |
|
65 | + return $event->getRenderedMessage(); |
|
66 | 66 | |
67 | - default: |
|
68 | - return ''; |
|
69 | - } |
|
70 | - } |
|
67 | + default: |
|
68 | + return ''; |
|
69 | + } |
|
70 | + } |
|
71 | 71 | } |
@@ -24,40 +24,40 @@ |
||
24 | 24 | */ |
25 | 25 | class LoggerLocationPatternConverter extends LoggerPatternConverter { |
26 | 26 | |
27 | - /** |
|
28 | - * @var integer |
|
29 | - */ |
|
30 | - private $type; |
|
27 | + /** |
|
28 | + * @var integer |
|
29 | + */ |
|
30 | + private $type; |
|
31 | 31 | |
32 | - /** |
|
33 | - * Constructor |
|
34 | - * |
|
35 | - * @param string $formattingInfo |
|
36 | - * @param integer $type |
|
37 | - */ |
|
38 | - public function __construct($formattingInfo, $type) { |
|
39 | - parent::__construct($formattingInfo); |
|
40 | - $this->type = $type; |
|
41 | - } |
|
32 | + /** |
|
33 | + * Constructor |
|
34 | + * |
|
35 | + * @param string $formattingInfo |
|
36 | + * @param integer $type |
|
37 | + */ |
|
38 | + public function __construct($formattingInfo, $type) { |
|
39 | + parent::__construct($formattingInfo); |
|
40 | + $this->type = $type; |
|
41 | + } |
|
42 | 42 | |
43 | - /** |
|
44 | - * @param LoggerLoggingEvent $event |
|
45 | - * @return string |
|
46 | - */ |
|
47 | - public function convert($event) { |
|
48 | - $locationInfo = $event->getLocationInformation(); |
|
49 | - switch($this->type) { |
|
50 | - case LoggerPatternParser::FULL_LOCATION_CONVERTER: |
|
51 | - return $locationInfo->getFullInfo(); |
|
52 | - case LoggerPatternParser::METHOD_LOCATION_CONVERTER: |
|
53 | - return $locationInfo->getMethodName(); |
|
54 | - case LoggerPatternParser::LINE_LOCATION_CONVERTER: |
|
55 | - return $locationInfo->getLineNumber(); |
|
56 | - case LoggerPatternParser::FILE_LOCATION_CONVERTER: |
|
57 | - return $locationInfo->getFileName(); |
|
58 | - default: |
|
59 | - return ''; |
|
60 | - } |
|
61 | - } |
|
43 | + /** |
|
44 | + * @param LoggerLoggingEvent $event |
|
45 | + * @return string |
|
46 | + */ |
|
47 | + public function convert($event) { |
|
48 | + $locationInfo = $event->getLocationInformation(); |
|
49 | + switch($this->type) { |
|
50 | + case LoggerPatternParser::FULL_LOCATION_CONVERTER: |
|
51 | + return $locationInfo->getFullInfo(); |
|
52 | + case LoggerPatternParser::METHOD_LOCATION_CONVERTER: |
|
53 | + return $locationInfo->getMethodName(); |
|
54 | + case LoggerPatternParser::LINE_LOCATION_CONVERTER: |
|
55 | + return $locationInfo->getLineNumber(); |
|
56 | + case LoggerPatternParser::FILE_LOCATION_CONVERTER: |
|
57 | + return $locationInfo->getFileName(); |
|
58 | + default: |
|
59 | + return ''; |
|
60 | + } |
|
61 | + } |
|
62 | 62 | } |
63 | 63 |
@@ -24,34 +24,34 @@ |
||
24 | 24 | */ |
25 | 25 | class LoggerLiteralPatternConverter extends LoggerPatternConverter { |
26 | 26 | |
27 | - /** |
|
28 | - * @var string |
|
29 | - */ |
|
30 | - private $literal; |
|
27 | + /** |
|
28 | + * @var string |
|
29 | + */ |
|
30 | + private $literal; |
|
31 | 31 | |
32 | - /** |
|
33 | - * Constructor |
|
34 | - * |
|
35 | - * @param string $value |
|
36 | - */ |
|
37 | - public function __construct($value) { |
|
38 | - $this->literal = $value; |
|
39 | - } |
|
32 | + /** |
|
33 | + * Constructor |
|
34 | + * |
|
35 | + * @param string $value |
|
36 | + */ |
|
37 | + public function __construct($value) { |
|
38 | + $this->literal = $value; |
|
39 | + } |
|
40 | 40 | |
41 | - /** |
|
42 | - * @param string &$sbuf |
|
43 | - * @param LoggerLoggingEvent $event |
|
44 | - */ |
|
45 | - public function format(&$sbuf, $event) { |
|
46 | - $sbuf .= $this->literal; |
|
47 | - } |
|
41 | + /** |
|
42 | + * @param string &$sbuf |
|
43 | + * @param LoggerLoggingEvent $event |
|
44 | + */ |
|
45 | + public function format(&$sbuf, $event) { |
|
46 | + $sbuf .= $this->literal; |
|
47 | + } |
|
48 | 48 | |
49 | - /** |
|
50 | - * @param LoggerLoggingEvent $event |
|
51 | - * @return string |
|
52 | - */ |
|
53 | - public function convert($event) { |
|
54 | - return $this->literal; |
|
55 | - } |
|
49 | + /** |
|
50 | + * @param LoggerLoggingEvent $event |
|
51 | + * @return string |
|
52 | + */ |
|
53 | + public function convert($event) { |
|
54 | + return $this->literal; |
|
55 | + } |
|
56 | 56 | } |
57 | 57 |
@@ -25,53 +25,53 @@ |
||
25 | 25 | */ |
26 | 26 | class LoggerNamedPatternConverter extends LoggerPatternConverter { |
27 | 27 | |
28 | - /** |
|
29 | - * @var integer |
|
30 | - */ |
|
31 | - private $precision; |
|
28 | + /** |
|
29 | + * @var integer |
|
30 | + */ |
|
31 | + private $precision; |
|
32 | 32 | |
33 | - /** |
|
34 | - * Constructor |
|
35 | - * |
|
36 | - * @param string $formattingInfo |
|
37 | - * @param integer $precision |
|
38 | - */ |
|
39 | - public function __construct($formattingInfo, $precision) { |
|
40 | - parent::__construct($formattingInfo); |
|
41 | - $this->precision = $precision; |
|
42 | - } |
|
33 | + /** |
|
34 | + * Constructor |
|
35 | + * |
|
36 | + * @param string $formattingInfo |
|
37 | + * @param integer $precision |
|
38 | + */ |
|
39 | + public function __construct($formattingInfo, $precision) { |
|
40 | + parent::__construct($formattingInfo); |
|
41 | + $this->precision = $precision; |
|
42 | + } |
|
43 | 43 | |
44 | - /** |
|
45 | - * @param LoggerLoggingEvent $event |
|
46 | - * @return string |
|
47 | - * @abstract |
|
48 | - */ |
|
49 | - public function getFullyQualifiedName($event) { |
|
50 | - // abstract |
|
51 | - return; |
|
52 | - } |
|
44 | + /** |
|
45 | + * @param LoggerLoggingEvent $event |
|
46 | + * @return string |
|
47 | + * @abstract |
|
48 | + */ |
|
49 | + public function getFullyQualifiedName($event) { |
|
50 | + // abstract |
|
51 | + return; |
|
52 | + } |
|
53 | 53 | |
54 | - /** |
|
55 | - * @param LoggerLoggingEvent $event |
|
56 | - * @return string |
|
57 | - */ |
|
58 | - function convert($event) { |
|
59 | - $n = $this->getFullyQualifiedName($event); |
|
60 | - if($this->precision <= 0) { |
|
61 | - return $n; |
|
62 | - } else { |
|
63 | - $len = strlen($n); |
|
64 | - // We substract 1 from 'len' when assigning to 'end' to avoid out of |
|
65 | - // bounds exception in return r.substring(end+1, len). This can happen if |
|
66 | - // precision is 1 and the category name ends with a dot. |
|
67 | - $end = $len -1 ; |
|
68 | - for($i = $this->precision; $i > 0; $i--) { |
|
69 | - $end = strrpos(substr($n, 0, ($end - 1)), '.'); |
|
70 | - if($end == false) { |
|
71 | - return $n; |
|
72 | - } |
|
73 | - } |
|
74 | - return substr($n, ($end + 1), $len); |
|
75 | - } |
|
76 | - } |
|
54 | + /** |
|
55 | + * @param LoggerLoggingEvent $event |
|
56 | + * @return string |
|
57 | + */ |
|
58 | + function convert($event) { |
|
59 | + $n = $this->getFullyQualifiedName($event); |
|
60 | + if($this->precision <= 0) { |
|
61 | + return $n; |
|
62 | + } else { |
|
63 | + $len = strlen($n); |
|
64 | + // We substract 1 from 'len' when assigning to 'end' to avoid out of |
|
65 | + // bounds exception in return r.substring(end+1, len). This can happen if |
|
66 | + // precision is 1 and the category name ends with a dot. |
|
67 | + $end = $len -1 ; |
|
68 | + for($i = $this->precision; $i > 0; $i--) { |
|
69 | + $end = strrpos(substr($n, 0, ($end - 1)), '.'); |
|
70 | + if($end == false) { |
|
71 | + return $n; |
|
72 | + } |
|
73 | + } |
|
74 | + return substr($n, ($end + 1), $len); |
|
75 | + } |
|
76 | + } |
|
77 | 77 | } |
@@ -43,14 +43,14 @@ |
||
43 | 43 | */ |
44 | 44 | class LoggerFilterDenyAll extends LoggerFilter { |
45 | 45 | |
46 | - /** |
|
47 | - * Always returns the integer constant {@link LoggerFilter::DENY} |
|
48 | - * regardless of the {@link LoggerLoggingEvent} parameter. |
|
49 | - * |
|
50 | - * @param LoggerLoggingEvent $event The {@link LoggerLoggingEvent} to filter. |
|
51 | - * @return LoggerFilter::DENY Always returns {@link LoggerFilter::DENY} |
|
52 | - */ |
|
53 | - public function decide(LoggerLoggingEvent $event) { |
|
54 | - return LoggerFilter::DENY; |
|
55 | - } |
|
46 | + /** |
|
47 | + * Always returns the integer constant {@link LoggerFilter::DENY} |
|
48 | + * regardless of the {@link LoggerLoggingEvent} parameter. |
|
49 | + * |
|
50 | + * @param LoggerLoggingEvent $event The {@link LoggerLoggingEvent} to filter. |
|
51 | + * @return LoggerFilter::DENY Always returns {@link LoggerFilter::DENY} |
|
52 | + */ |
|
53 | + public function decide(LoggerLoggingEvent $event) { |
|
54 | + return LoggerFilter::DENY; |
|
55 | + } |
|
56 | 56 | } |
@@ -31,17 +31,17 @@ |
||
31 | 31 | */ |
32 | 32 | class LoggerConfiguratorBasic implements LoggerConfigurator { |
33 | 33 | |
34 | - /** |
|
35 | - * Add a {@link LoggerAppenderConsole} that uses |
|
36 | - * the {@link LoggerLayoutTTCC} to the root category. |
|
37 | - * |
|
38 | - * @param string $url not used here |
|
39 | - */ |
|
40 | - public function configure(LoggerHierarchy $hierarchy, $url = null) { |
|
41 | - $root = $hierarchy->getRootLogger(); |
|
42 | - $appender = new LoggerAppenderConsole('A1'); |
|
43 | - $appender->setLayout( new LoggerLayoutTTCC() ); |
|
44 | - $appender->activateOptions(); |
|
45 | - $root->addAppender($appender); |
|
46 | - } |
|
34 | + /** |
|
35 | + * Add a {@link LoggerAppenderConsole} that uses |
|
36 | + * the {@link LoggerLayoutTTCC} to the root category. |
|
37 | + * |
|
38 | + * @param string $url not used here |
|
39 | + */ |
|
40 | + public function configure(LoggerHierarchy $hierarchy, $url = null) { |
|
41 | + $root = $hierarchy->getRootLogger(); |
|
42 | + $appender = new LoggerAppenderConsole('A1'); |
|
43 | + $appender->setLayout( new LoggerLayoutTTCC() ); |
|
44 | + $appender->activateOptions(); |
|
45 | + $root->addAppender($appender); |
|
46 | + } |
|
47 | 47 | } |
@@ -33,224 +33,224 @@ |
||
33 | 33 | */ |
34 | 34 | class LoggerLevel { |
35 | 35 | |
36 | - const OFF = 2147483647; |
|
37 | - const FATAL = 50000; |
|
38 | - const ERROR = 40000; |
|
39 | - const WARN = 30000; |
|
40 | - const INFO = 20000; |
|
41 | - const DEBUG = 10000; |
|
42 | - const ALL = -2147483647; |
|
36 | + const OFF = 2147483647; |
|
37 | + const FATAL = 50000; |
|
38 | + const ERROR = 40000; |
|
39 | + const WARN = 30000; |
|
40 | + const INFO = 20000; |
|
41 | + const DEBUG = 10000; |
|
42 | + const ALL = -2147483647; |
|
43 | 43 | |
44 | - /** |
|
45 | - * TODO: check if still necessary or to be refactored |
|
46 | - * @var integer |
|
47 | - */ |
|
48 | - private $level; |
|
44 | + /** |
|
45 | + * TODO: check if still necessary or to be refactored |
|
46 | + * @var integer |
|
47 | + */ |
|
48 | + private $level; |
|
49 | 49 | |
50 | - /** |
|
51 | - * Contains a list of instantiated levels |
|
52 | - */ |
|
53 | - private static $levelMap; |
|
50 | + /** |
|
51 | + * Contains a list of instantiated levels |
|
52 | + */ |
|
53 | + private static $levelMap; |
|
54 | 54 | |
55 | - /** |
|
56 | - * @var string |
|
57 | - */ |
|
58 | - private $levelStr; |
|
55 | + /** |
|
56 | + * @var string |
|
57 | + */ |
|
58 | + private $levelStr; |
|
59 | 59 | |
60 | - /** |
|
61 | - * @var integer |
|
62 | - */ |
|
63 | - private $syslogEquivalent; |
|
60 | + /** |
|
61 | + * @var integer |
|
62 | + */ |
|
63 | + private $syslogEquivalent; |
|
64 | 64 | |
65 | - /** |
|
66 | - * Constructor |
|
67 | - * |
|
68 | - * @param integer $level |
|
69 | - * @param string $levelStr |
|
70 | - * @param integer $syslogEquivalent |
|
71 | - */ |
|
72 | - private function __construct($level, $levelStr, $syslogEquivalent) { |
|
73 | - $this->level = $level; |
|
74 | - $this->levelStr = $levelStr; |
|
75 | - $this->syslogEquivalent = $syslogEquivalent; |
|
76 | - } |
|
65 | + /** |
|
66 | + * Constructor |
|
67 | + * |
|
68 | + * @param integer $level |
|
69 | + * @param string $levelStr |
|
70 | + * @param integer $syslogEquivalent |
|
71 | + */ |
|
72 | + private function __construct($level, $levelStr, $syslogEquivalent) { |
|
73 | + $this->level = $level; |
|
74 | + $this->levelStr = $levelStr; |
|
75 | + $this->syslogEquivalent = $syslogEquivalent; |
|
76 | + } |
|
77 | 77 | |
78 | - /** |
|
79 | - * Two priorities are equal if their level fields are equal. |
|
80 | - * |
|
81 | - * @param object $o |
|
82 | - * @return boolean |
|
83 | - */ |
|
84 | - public function equals($o) { |
|
85 | - if($o instanceof LoggerLevel) { |
|
86 | - if($this->level == $o->level) { |
|
87 | - return true; |
|
88 | - } |
|
89 | - } else { |
|
90 | - return false; |
|
91 | - } |
|
92 | - } |
|
78 | + /** |
|
79 | + * Two priorities are equal if their level fields are equal. |
|
80 | + * |
|
81 | + * @param object $o |
|
82 | + * @return boolean |
|
83 | + */ |
|
84 | + public function equals($o) { |
|
85 | + if($o instanceof LoggerLevel) { |
|
86 | + if($this->level == $o->level) { |
|
87 | + return true; |
|
88 | + } |
|
89 | + } else { |
|
90 | + return false; |
|
91 | + } |
|
92 | + } |
|
93 | 93 | |
94 | - /** |
|
95 | - * Returns an Off Level |
|
96 | - * @static |
|
97 | - * @return LoggerLevel |
|
98 | - */ |
|
99 | - public static function getLevelOff() { |
|
100 | - if(!isset(self::$levelMap[LoggerLevel::OFF])) { |
|
101 | - self::$levelMap[LoggerLevel::OFF] = new LoggerLevel(LoggerLevel::OFF, 'OFF', 0); |
|
102 | - } |
|
103 | - return self::$levelMap[LoggerLevel::OFF]; |
|
104 | - } |
|
94 | + /** |
|
95 | + * Returns an Off Level |
|
96 | + * @static |
|
97 | + * @return LoggerLevel |
|
98 | + */ |
|
99 | + public static function getLevelOff() { |
|
100 | + if(!isset(self::$levelMap[LoggerLevel::OFF])) { |
|
101 | + self::$levelMap[LoggerLevel::OFF] = new LoggerLevel(LoggerLevel::OFF, 'OFF', 0); |
|
102 | + } |
|
103 | + return self::$levelMap[LoggerLevel::OFF]; |
|
104 | + } |
|
105 | 105 | |
106 | - /** |
|
107 | - * Returns a Fatal Level |
|
108 | - * @static |
|
109 | - * @return LoggerLevel |
|
110 | - */ |
|
111 | - public static function getLevelFatal() { |
|
112 | - if(!isset(self::$levelMap[LoggerLevel::FATAL])) { |
|
113 | - self::$levelMap[LoggerLevel::FATAL] = new LoggerLevel(LoggerLevel::FATAL, 'FATAL', 0); |
|
114 | - } |
|
115 | - return self::$levelMap[LoggerLevel::FATAL]; |
|
116 | - } |
|
106 | + /** |
|
107 | + * Returns a Fatal Level |
|
108 | + * @static |
|
109 | + * @return LoggerLevel |
|
110 | + */ |
|
111 | + public static function getLevelFatal() { |
|
112 | + if(!isset(self::$levelMap[LoggerLevel::FATAL])) { |
|
113 | + self::$levelMap[LoggerLevel::FATAL] = new LoggerLevel(LoggerLevel::FATAL, 'FATAL', 0); |
|
114 | + } |
|
115 | + return self::$levelMap[LoggerLevel::FATAL]; |
|
116 | + } |
|
117 | 117 | |
118 | - /** |
|
119 | - * Returns an Error Level |
|
120 | - * @static |
|
121 | - * @return LoggerLevel |
|
122 | - */ |
|
123 | - public static function getLevelError() { |
|
124 | - if(!isset(self::$levelMap[LoggerLevel::ERROR])) { |
|
125 | - self::$levelMap[LoggerLevel::ERROR] = new LoggerLevel(LoggerLevel::ERROR, 'ERROR', 3); |
|
126 | - } |
|
127 | - return self::$levelMap[LoggerLevel::ERROR]; |
|
128 | - } |
|
118 | + /** |
|
119 | + * Returns an Error Level |
|
120 | + * @static |
|
121 | + * @return LoggerLevel |
|
122 | + */ |
|
123 | + public static function getLevelError() { |
|
124 | + if(!isset(self::$levelMap[LoggerLevel::ERROR])) { |
|
125 | + self::$levelMap[LoggerLevel::ERROR] = new LoggerLevel(LoggerLevel::ERROR, 'ERROR', 3); |
|
126 | + } |
|
127 | + return self::$levelMap[LoggerLevel::ERROR]; |
|
128 | + } |
|
129 | 129 | |
130 | - /** |
|
131 | - * Returns a Warn Level |
|
132 | - * @static |
|
133 | - * @return LoggerLevel |
|
134 | - */ |
|
135 | - public static function getLevelWarn() { |
|
136 | - if(!isset(self::$levelMap[LoggerLevel::WARN])) { |
|
137 | - self::$levelMap[LoggerLevel::WARN] = new LoggerLevel(LoggerLevel::WARN, 'WARN', 4); |
|
138 | - } |
|
139 | - return self::$levelMap[LoggerLevel::WARN]; |
|
140 | - } |
|
130 | + /** |
|
131 | + * Returns a Warn Level |
|
132 | + * @static |
|
133 | + * @return LoggerLevel |
|
134 | + */ |
|
135 | + public static function getLevelWarn() { |
|
136 | + if(!isset(self::$levelMap[LoggerLevel::WARN])) { |
|
137 | + self::$levelMap[LoggerLevel::WARN] = new LoggerLevel(LoggerLevel::WARN, 'WARN', 4); |
|
138 | + } |
|
139 | + return self::$levelMap[LoggerLevel::WARN]; |
|
140 | + } |
|
141 | 141 | |
142 | - /** |
|
143 | - * Returns an Info Level |
|
144 | - * @static |
|
145 | - * @return LoggerLevel |
|
146 | - */ |
|
147 | - public static function getLevelInfo() { |
|
148 | - if(!isset(self::$levelMap[LoggerLevel::INFO])) { |
|
149 | - self::$levelMap[LoggerLevel::INFO] = new LoggerLevel(LoggerLevel::INFO, 'INFO', 6); |
|
150 | - } |
|
151 | - return self::$levelMap[LoggerLevel::INFO]; |
|
152 | - } |
|
142 | + /** |
|
143 | + * Returns an Info Level |
|
144 | + * @static |
|
145 | + * @return LoggerLevel |
|
146 | + */ |
|
147 | + public static function getLevelInfo() { |
|
148 | + if(!isset(self::$levelMap[LoggerLevel::INFO])) { |
|
149 | + self::$levelMap[LoggerLevel::INFO] = new LoggerLevel(LoggerLevel::INFO, 'INFO', 6); |
|
150 | + } |
|
151 | + return self::$levelMap[LoggerLevel::INFO]; |
|
152 | + } |
|
153 | 153 | |
154 | - /** |
|
155 | - * Returns a Debug Level |
|
156 | - * @static |
|
157 | - * @return LoggerLevel |
|
158 | - */ |
|
159 | - public static function getLevelDebug() { |
|
160 | - if(!isset(self::$levelMap[LoggerLevel::DEBUG])) { |
|
161 | - self::$levelMap[LoggerLevel::DEBUG] = new LoggerLevel(LoggerLevel::DEBUG, 'DEBUG', 7); |
|
162 | - } |
|
163 | - return self::$levelMap[LoggerLevel::DEBUG]; |
|
164 | - } |
|
154 | + /** |
|
155 | + * Returns a Debug Level |
|
156 | + * @static |
|
157 | + * @return LoggerLevel |
|
158 | + */ |
|
159 | + public static function getLevelDebug() { |
|
160 | + if(!isset(self::$levelMap[LoggerLevel::DEBUG])) { |
|
161 | + self::$levelMap[LoggerLevel::DEBUG] = new LoggerLevel(LoggerLevel::DEBUG, 'DEBUG', 7); |
|
162 | + } |
|
163 | + return self::$levelMap[LoggerLevel::DEBUG]; |
|
164 | + } |
|
165 | 165 | |
166 | - /** |
|
167 | - * Returns an All Level |
|
168 | - * @static |
|
169 | - * @return LoggerLevel |
|
170 | - */ |
|
171 | - public static function getLevelAll() { |
|
172 | - if(!isset(self::$levelMap[LoggerLevel::ALL])) { |
|
173 | - self::$levelMap[LoggerLevel::ALL] = new LoggerLevel(LoggerLevel::ALL, 'ALL', 7); |
|
174 | - } |
|
175 | - return self::$levelMap[LoggerLevel::ALL]; |
|
176 | - } |
|
166 | + /** |
|
167 | + * Returns an All Level |
|
168 | + * @static |
|
169 | + * @return LoggerLevel |
|
170 | + */ |
|
171 | + public static function getLevelAll() { |
|
172 | + if(!isset(self::$levelMap[LoggerLevel::ALL])) { |
|
173 | + self::$levelMap[LoggerLevel::ALL] = new LoggerLevel(LoggerLevel::ALL, 'ALL', 7); |
|
174 | + } |
|
175 | + return self::$levelMap[LoggerLevel::ALL]; |
|
176 | + } |
|
177 | 177 | |
178 | - /** |
|
179 | - * Return the syslog equivalent of this priority as an integer. |
|
180 | - * @final |
|
181 | - * @return integer |
|
182 | - */ |
|
183 | - public function getSyslogEquivalent() { |
|
184 | - return $this->syslogEquivalent; |
|
185 | - } |
|
178 | + /** |
|
179 | + * Return the syslog equivalent of this priority as an integer. |
|
180 | + * @final |
|
181 | + * @return integer |
|
182 | + */ |
|
183 | + public function getSyslogEquivalent() { |
|
184 | + return $this->syslogEquivalent; |
|
185 | + } |
|
186 | 186 | |
187 | - /** |
|
188 | - * Returns <i>true</i> if this level has a higher or equal |
|
189 | - * level than the level passed as argument, <i>false</i> |
|
190 | - * otherwise. |
|
191 | - * |
|
192 | - * <p>You should think twice before overriding the default |
|
193 | - * implementation of <i>isGreaterOrEqual</i> method. |
|
194 | - * |
|
195 | - * @param LoggerLevel $r |
|
196 | - * @return boolean |
|
197 | - */ |
|
198 | - public function isGreaterOrEqual($r) { |
|
199 | - return $this->level >= $r->level; |
|
200 | - } |
|
187 | + /** |
|
188 | + * Returns <i>true</i> if this level has a higher or equal |
|
189 | + * level than the level passed as argument, <i>false</i> |
|
190 | + * otherwise. |
|
191 | + * |
|
192 | + * <p>You should think twice before overriding the default |
|
193 | + * implementation of <i>isGreaterOrEqual</i> method. |
|
194 | + * |
|
195 | + * @param LoggerLevel $r |
|
196 | + * @return boolean |
|
197 | + */ |
|
198 | + public function isGreaterOrEqual($r) { |
|
199 | + return $this->level >= $r->level; |
|
200 | + } |
|
201 | 201 | |
202 | - /** |
|
203 | - * Returns the string representation of this priority. |
|
204 | - * @return string |
|
205 | - * @final |
|
206 | - */ |
|
207 | - public function toString() { |
|
208 | - return $this->levelStr; |
|
209 | - } |
|
202 | + /** |
|
203 | + * Returns the string representation of this priority. |
|
204 | + * @return string |
|
205 | + * @final |
|
206 | + */ |
|
207 | + public function toString() { |
|
208 | + return $this->levelStr; |
|
209 | + } |
|
210 | 210 | |
211 | - /** |
|
212 | - * Returns the integer representation of this level. |
|
213 | - * @return integer |
|
214 | - */ |
|
215 | - public function toInt() { |
|
216 | - return $this->level; |
|
217 | - } |
|
211 | + /** |
|
212 | + * Returns the integer representation of this level. |
|
213 | + * @return integer |
|
214 | + */ |
|
215 | + public function toInt() { |
|
216 | + return $this->level; |
|
217 | + } |
|
218 | 218 | |
219 | - /** |
|
220 | - * Convert the string passed as argument to a level. If the |
|
221 | - * conversion fails, then this method returns a DEBUG Level. |
|
222 | - * |
|
223 | - * @param mixed $arg |
|
224 | - * @param LoggerLevel $default |
|
225 | - * @static |
|
226 | - */ |
|
227 | - public static function toLevel($arg, $defaultLevel = null) { |
|
228 | - if($defaultLevel === null) { |
|
229 | - return self::toLevel($arg, self::getLevelDebug()); |
|
230 | - } else { |
|
231 | - if(is_int($arg)) { |
|
232 | - switch($arg) { |
|
233 | - case self::ALL: return self::getLevelAll(); |
|
234 | - case self::DEBUG: return self::getLevelDebug(); |
|
235 | - case self::INFO: return self::getLevelInfo(); |
|
236 | - case self::WARN: return self::getLevelWarn(); |
|
237 | - case self::ERROR: return self::getLevelError(); |
|
238 | - case self::FATAL: return self::getLevelFatal(); |
|
239 | - case self::OFF: return self::getLevelOff(); |
|
240 | - default: return $defaultLevel; |
|
241 | - } |
|
242 | - } else { |
|
243 | - switch(strtoupper($arg)) { |
|
244 | - case 'ALL': return self::getLevelAll(); |
|
245 | - case 'DEBUG': return self::getLevelDebug(); |
|
246 | - case 'INFO': return self::getLevelInfo(); |
|
247 | - case 'WARN': return self::getLevelWarn(); |
|
248 | - case 'ERROR': return self::getLevelError(); |
|
249 | - case 'FATAL': return self::getLevelFatal(); |
|
250 | - case 'OFF': return self::getLevelOff(); |
|
251 | - default: return $defaultLevel; |
|
252 | - } |
|
253 | - } |
|
254 | - } |
|
255 | - } |
|
219 | + /** |
|
220 | + * Convert the string passed as argument to a level. If the |
|
221 | + * conversion fails, then this method returns a DEBUG Level. |
|
222 | + * |
|
223 | + * @param mixed $arg |
|
224 | + * @param LoggerLevel $default |
|
225 | + * @static |
|
226 | + */ |
|
227 | + public static function toLevel($arg, $defaultLevel = null) { |
|
228 | + if($defaultLevel === null) { |
|
229 | + return self::toLevel($arg, self::getLevelDebug()); |
|
230 | + } else { |
|
231 | + if(is_int($arg)) { |
|
232 | + switch($arg) { |
|
233 | + case self::ALL: return self::getLevelAll(); |
|
234 | + case self::DEBUG: return self::getLevelDebug(); |
|
235 | + case self::INFO: return self::getLevelInfo(); |
|
236 | + case self::WARN: return self::getLevelWarn(); |
|
237 | + case self::ERROR: return self::getLevelError(); |
|
238 | + case self::FATAL: return self::getLevelFatal(); |
|
239 | + case self::OFF: return self::getLevelOff(); |
|
240 | + default: return $defaultLevel; |
|
241 | + } |
|
242 | + } else { |
|
243 | + switch(strtoupper($arg)) { |
|
244 | + case 'ALL': return self::getLevelAll(); |
|
245 | + case 'DEBUG': return self::getLevelDebug(); |
|
246 | + case 'INFO': return self::getLevelInfo(); |
|
247 | + case 'WARN': return self::getLevelWarn(); |
|
248 | + case 'ERROR': return self::getLevelError(); |
|
249 | + case 'FATAL': return self::getLevelFatal(); |
|
250 | + case 'OFF': return self::getLevelOff(); |
|
251 | + default: return $defaultLevel; |
|
252 | + } |
|
253 | + } |
|
254 | + } |
|
255 | + } |
|
256 | 256 | } |
@@ -48,183 +48,183 @@ |
||
48 | 48 | */ |
49 | 49 | class LoggerAppenderRollingFile extends 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 | - private $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 | + private $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 | - private $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 | + private $maxBackupIndex = 1; |
|
82 | 82 | |
83 | - /** |
|
84 | - * @var string the filename expanded |
|
85 | - * @access private |
|
86 | - */ |
|
87 | - private $expandedFileName = null; |
|
83 | + /** |
|
84 | + * @var string the filename expanded |
|
85 | + * @access private |
|
86 | + */ |
|
87 | + private $expandedFileName = null; |
|
88 | 88 | |
89 | - public function __destruct() { |
|
90 | - parent::__destruct(); |
|
91 | - } |
|
89 | + public function __destruct() { |
|
90 | + parent::__destruct(); |
|
91 | + } |
|
92 | 92 | |
93 | - /** |
|
94 | - * Returns the value of the MaxBackupIndex option. |
|
95 | - * @return integer |
|
96 | - */ |
|
97 | - private function getExpandedFileName() { |
|
98 | - return $this->expandedFileName; |
|
99 | - } |
|
93 | + /** |
|
94 | + * Returns the value of the MaxBackupIndex option. |
|
95 | + * @return integer |
|
96 | + */ |
|
97 | + private function getExpandedFileName() { |
|
98 | + return $this->expandedFileName; |
|
99 | + } |
|
100 | 100 | |
101 | - /** |
|
102 | - * Get the maximum size that the output file is allowed to reach |
|
103 | - * before being rolled over to backup files. |
|
104 | - * @return integer |
|
105 | - */ |
|
106 | - private function getMaximumFileSize() { |
|
107 | - return $this->maxFileSize; |
|
108 | - } |
|
101 | + /** |
|
102 | + * Get the maximum size that the output file is allowed to reach |
|
103 | + * before being rolled over to backup files. |
|
104 | + * @return integer |
|
105 | + */ |
|
106 | + private function getMaximumFileSize() { |
|
107 | + return $this->maxFileSize; |
|
108 | + } |
|
109 | 109 | |
110 | - /** |
|
111 | - * Implements the usual roll over behaviour. |
|
112 | - * |
|
113 | - * <p>If MaxBackupIndex is positive, then files File.1, ..., File.MaxBackupIndex -1 are renamed to File.2, ..., File.MaxBackupIndex. |
|
114 | - * Moreover, File is renamed File.1 and closed. A new File is created to receive further log output. |
|
115 | - * |
|
116 | - * <p>If MaxBackupIndex is equal to zero, then the File is truncated with no backup files created. |
|
117 | - */ |
|
118 | - private function rollOver() { |
|
119 | - // If maxBackups <= 0, then there is no file renaming to be done. |
|
120 | - if($this->maxBackupIndex > 0) { |
|
121 | - $fileName = $this->getExpandedFileName(); |
|
122 | - // Delete the oldest file, to keep Windows happy. |
|
123 | - $file = $fileName . '.' . $this->maxBackupIndex; |
|
124 | - if(is_writable($file)) |
|
125 | - unlink($file); |
|
126 | - // Map {(maxBackupIndex - 1), ..., 2, 1} to {maxBackupIndex, ..., 3, 2} |
|
127 | - for($i = $this->maxBackupIndex - 1; $i >= 1; $i--) { |
|
128 | - $file = $fileName . "." . $i; |
|
129 | - if(is_readable($file)) { |
|
130 | - $target = $fileName . '.' . ($i + 1); |
|
131 | - rename($file, $target); |
|
132 | - } |
|
133 | - } |
|
110 | + /** |
|
111 | + * Implements the usual roll over behaviour. |
|
112 | + * |
|
113 | + * <p>If MaxBackupIndex is positive, then files File.1, ..., File.MaxBackupIndex -1 are renamed to File.2, ..., File.MaxBackupIndex. |
|
114 | + * Moreover, File is renamed File.1 and closed. A new File is created to receive further log output. |
|
115 | + * |
|
116 | + * <p>If MaxBackupIndex is equal to zero, then the File is truncated with no backup files created. |
|
117 | + */ |
|
118 | + private function rollOver() { |
|
119 | + // If maxBackups <= 0, then there is no file renaming to be done. |
|
120 | + if($this->maxBackupIndex > 0) { |
|
121 | + $fileName = $this->getExpandedFileName(); |
|
122 | + // Delete the oldest file, to keep Windows happy. |
|
123 | + $file = $fileName . '.' . $this->maxBackupIndex; |
|
124 | + if(is_writable($file)) |
|
125 | + unlink($file); |
|
126 | + // Map {(maxBackupIndex - 1), ..., 2, 1} to {maxBackupIndex, ..., 3, 2} |
|
127 | + for($i = $this->maxBackupIndex - 1; $i >= 1; $i--) { |
|
128 | + $file = $fileName . "." . $i; |
|
129 | + if(is_readable($file)) { |
|
130 | + $target = $fileName . '.' . ($i + 1); |
|
131 | + rename($file, $target); |
|
132 | + } |
|
133 | + } |
|
134 | 134 | |
135 | - $this->close(); |
|
135 | + $this->close(); |
|
136 | 136 | |
137 | - // Rename fileName to fileName.1 |
|
138 | - $target = $fileName . ".1"; |
|
139 | - $file = $fileName; |
|
140 | - rename($file, $target); |
|
141 | - } |
|
137 | + // Rename fileName to fileName.1 |
|
138 | + $target = $fileName . ".1"; |
|
139 | + $file = $fileName; |
|
140 | + rename($file, $target); |
|
141 | + } |
|
142 | 142 | |
143 | - //unset($this->fp); |
|
144 | - $this->activateOptions(); |
|
145 | - $this->setFile($fileName, false); |
|
146 | - } |
|
143 | + //unset($this->fp); |
|
144 | + $this->activateOptions(); |
|
145 | + $this->setFile($fileName, false); |
|
146 | + } |
|
147 | 147 | |
148 | - public function setFileName($fileName) { |
|
149 | - $this->fileName = $fileName; |
|
150 | - // As LoggerAppenderFile does not create the directory, it has to exist. |
|
151 | - // realpath() fails if the argument does not exist so the filename is separated. |
|
152 | - $this->expandedFileName = realpath(dirname($fileName)); |
|
153 | - if ($this->expandedFileName === false) throw new Exception("Directory of $fileName does not exist!"); |
|
154 | - $this->expandedFileName .= '/'.basename($fileName); |
|
155 | - } |
|
148 | + public function setFileName($fileName) { |
|
149 | + $this->fileName = $fileName; |
|
150 | + // As LoggerAppenderFile does not create the directory, it has to exist. |
|
151 | + // realpath() fails if the argument does not exist so the filename is separated. |
|
152 | + $this->expandedFileName = realpath(dirname($fileName)); |
|
153 | + if ($this->expandedFileName === false) throw new Exception("Directory of $fileName does not exist!"); |
|
154 | + $this->expandedFileName .= '/'.basename($fileName); |
|
155 | + } |
|
156 | 156 | |
157 | 157 | |
158 | - /** |
|
159 | - * Set the maximum number of backup files to keep around. |
|
160 | - * |
|
161 | - * <p>The <b>MaxBackupIndex</b> option determines how many backup |
|
162 | - * files are kept before the oldest is erased. This option takes |
|
163 | - * a positive integer value. If set to zero, then there will be no |
|
164 | - * backup files and the log file will be truncated when it reaches |
|
165 | - * MaxFileSize. |
|
166 | - * |
|
167 | - * @param mixed $maxBackups |
|
168 | - */ |
|
169 | - public function setMaxBackupIndex($maxBackups) { |
|
170 | - if(is_numeric($maxBackups)) { |
|
171 | - $this->maxBackupIndex = abs((int)$maxBackups); |
|
172 | - } |
|
173 | - } |
|
158 | + /** |
|
159 | + * Set the maximum number of backup files to keep around. |
|
160 | + * |
|
161 | + * <p>The <b>MaxBackupIndex</b> option determines how many backup |
|
162 | + * files are kept before the oldest is erased. This option takes |
|
163 | + * a positive integer value. If set to zero, then there will be no |
|
164 | + * backup files and the log file will be truncated when it reaches |
|
165 | + * MaxFileSize. |
|
166 | + * |
|
167 | + * @param mixed $maxBackups |
|
168 | + */ |
|
169 | + public function setMaxBackupIndex($maxBackups) { |
|
170 | + if(is_numeric($maxBackups)) { |
|
171 | + $this->maxBackupIndex = abs((int)$maxBackups); |
|
172 | + } |
|
173 | + } |
|
174 | 174 | |
175 | - /** |
|
176 | - * Set the maximum size that the output file is allowed to reach |
|
177 | - * before being rolled over to backup files. |
|
178 | - * |
|
179 | - * @param mixed $maxFileSize |
|
180 | - * @see setMaxFileSize() |
|
181 | - * @deprecated |
|
182 | - */ |
|
183 | - public function setMaximumFileSize($maxFileSize) { |
|
184 | - return $this->setMaxFileSize($maxFileSize); |
|
185 | - } |
|
175 | + /** |
|
176 | + * Set the maximum size that the output file is allowed to reach |
|
177 | + * before being rolled over to backup files. |
|
178 | + * |
|
179 | + * @param mixed $maxFileSize |
|
180 | + * @see setMaxFileSize() |
|
181 | + * @deprecated |
|
182 | + */ |
|
183 | + public function setMaximumFileSize($maxFileSize) { |
|
184 | + return $this->setMaxFileSize($maxFileSize); |
|
185 | + } |
|
186 | 186 | |
187 | - /** |
|
188 | - * Set the maximum size that the output file is allowed to reach |
|
189 | - * before being rolled over to backup files. |
|
190 | - * <p>In configuration files, the <b>MaxFileSize</b> option takes an |
|
191 | - * long integer in the range 0 - 2^63. You can specify the value |
|
192 | - * with the suffixes "KB", "MB" or "GB" so that the integer is |
|
193 | - * interpreted being expressed respectively in kilobytes, megabytes |
|
194 | - * or gigabytes. For example, the value "10KB" will be interpreted |
|
195 | - * as 10240. |
|
196 | - * |
|
197 | - * @param mixed $value |
|
198 | - * @return the actual file size set |
|
199 | - */ |
|
200 | - public function setMaxFileSize($value) { |
|
201 | - $maxFileSize = null; |
|
202 | - $numpart = substr($value,0, strlen($value) -2); |
|
203 | - $suffix = strtoupper(substr($value, -2)); |
|
187 | + /** |
|
188 | + * Set the maximum size that the output file is allowed to reach |
|
189 | + * before being rolled over to backup files. |
|
190 | + * <p>In configuration files, the <b>MaxFileSize</b> option takes an |
|
191 | + * long integer in the range 0 - 2^63. You can specify the value |
|
192 | + * with the suffixes "KB", "MB" or "GB" so that the integer is |
|
193 | + * interpreted being expressed respectively in kilobytes, megabytes |
|
194 | + * or gigabytes. For example, the value "10KB" will be interpreted |
|
195 | + * as 10240. |
|
196 | + * |
|
197 | + * @param mixed $value |
|
198 | + * @return the actual file size set |
|
199 | + */ |
|
200 | + public function setMaxFileSize($value) { |
|
201 | + $maxFileSize = null; |
|
202 | + $numpart = substr($value,0, strlen($value) -2); |
|
203 | + $suffix = strtoupper(substr($value, -2)); |
|
204 | 204 | |
205 | - switch($suffix) { |
|
206 | - case 'KB': $maxFileSize = (int)((int)$numpart * 1024); break; |
|
207 | - case 'MB': $maxFileSize = (int)((int)$numpart * 1024 * 1024); break; |
|
208 | - case 'GB': $maxFileSize = (int)((int)$numpart * 1024 * 1024 * 1024); break; |
|
209 | - default: |
|
210 | - if(is_numeric($value)) { |
|
211 | - $maxFileSize = (int)$value; |
|
212 | - } |
|
213 | - } |
|
205 | + switch($suffix) { |
|
206 | + case 'KB': $maxFileSize = (int)((int)$numpart * 1024); break; |
|
207 | + case 'MB': $maxFileSize = (int)((int)$numpart * 1024 * 1024); break; |
|
208 | + case 'GB': $maxFileSize = (int)((int)$numpart * 1024 * 1024 * 1024); break; |
|
209 | + default: |
|
210 | + if(is_numeric($value)) { |
|
211 | + $maxFileSize = (int)$value; |
|
212 | + } |
|
213 | + } |
|
214 | 214 | |
215 | - if($maxFileSize !== null) { |
|
216 | - $this->maxFileSize = abs($maxFileSize); |
|
217 | - } |
|
218 | - return $this->maxFileSize; |
|
219 | - } |
|
215 | + if($maxFileSize !== null) { |
|
216 | + $this->maxFileSize = abs($maxFileSize); |
|
217 | + } |
|
218 | + return $this->maxFileSize; |
|
219 | + } |
|
220 | 220 | |
221 | - /** |
|
222 | - * @param LoggerLoggingEvent $event |
|
223 | - */ |
|
224 | - public function append(LoggerLoggingEvent $event) { |
|
225 | - parent::append($event); |
|
226 | - if(ftell($this->fp) > $this->getMaximumFileSize()) { |
|
227 | - $this->rollOver(); |
|
228 | - } |
|
229 | - } |
|
221 | + /** |
|
222 | + * @param LoggerLoggingEvent $event |
|
223 | + */ |
|
224 | + public function append(LoggerLoggingEvent $event) { |
|
225 | + parent::append($event); |
|
226 | + if(ftell($this->fp) > $this->getMaximumFileSize()) { |
|
227 | + $this->rollOver(); |
|
228 | + } |
|
229 | + } |
|
230 | 230 | } |
@@ -53,160 +53,160 @@ |
||
53 | 53 | */ |
54 | 54 | class LoggerAppenderSyslog extends LoggerAppender { |
55 | 55 | |
56 | - /** |
|
57 | - * The ident string is added to each message. Typically the name of your application. |
|
58 | - * |
|
59 | - * @var string Ident for your application |
|
60 | - */ |
|
61 | - private $_ident = "Log4PHP Syslog-Event"; |
|
56 | + /** |
|
57 | + * The ident string is added to each message. Typically the name of your application. |
|
58 | + * |
|
59 | + * @var string Ident for your application |
|
60 | + */ |
|
61 | + private $_ident = "Log4PHP Syslog-Event"; |
|
62 | 62 | |
63 | - /** |
|
64 | - * The priority parameter value indicates the level of importance of the message. |
|
65 | - * It is passed on to the Syslog daemon. |
|
66 | - * |
|
67 | - * @var int Syslog priority |
|
68 | - */ |
|
69 | - private $_priority; |
|
63 | + /** |
|
64 | + * The priority parameter value indicates the level of importance of the message. |
|
65 | + * It is passed on to the Syslog daemon. |
|
66 | + * |
|
67 | + * @var int Syslog priority |
|
68 | + */ |
|
69 | + private $_priority; |
|
70 | 70 | |
71 | - /** |
|
72 | - * The option used when generating a log message. |
|
73 | - * It is passed on to the Syslog daemon. |
|
74 | - * |
|
75 | - * @var int Syslog priority |
|
76 | - */ |
|
77 | - private $_option; |
|
71 | + /** |
|
72 | + * The option used when generating a log message. |
|
73 | + * It is passed on to the Syslog daemon. |
|
74 | + * |
|
75 | + * @var int Syslog priority |
|
76 | + */ |
|
77 | + private $_option; |
|
78 | 78 | |
79 | - /** |
|
80 | - * The facility value indicates the source of the message. |
|
81 | - * It is passed on to the Syslog daemon. |
|
82 | - * |
|
83 | - * @var const int Syslog facility |
|
84 | - */ |
|
85 | - private $_facility; |
|
79 | + /** |
|
80 | + * The facility value indicates the source of the message. |
|
81 | + * It is passed on to the Syslog daemon. |
|
82 | + * |
|
83 | + * @var const int Syslog facility |
|
84 | + */ |
|
85 | + private $_facility; |
|
86 | 86 | |
87 | - /** |
|
88 | - * If it is necessary to define logging priority in the .properties-file, |
|
89 | - * set this variable to "true". |
|
90 | - * |
|
91 | - * @var const int value indicating whether the priority of the message is defined in the .properties-file |
|
92 | - * (or properties-array) |
|
93 | - */ |
|
94 | - private $_overridePriority; |
|
87 | + /** |
|
88 | + * If it is necessary to define logging priority in the .properties-file, |
|
89 | + * set this variable to "true". |
|
90 | + * |
|
91 | + * @var const int value indicating whether the priority of the message is defined in the .properties-file |
|
92 | + * (or properties-array) |
|
93 | + */ |
|
94 | + private $_overridePriority; |
|
95 | 95 | |
96 | - /** @var indiciates if this appender should run in dry mode */ |
|
97 | - private $dry = false; |
|
96 | + /** @var indiciates if this appender should run in dry mode */ |
|
97 | + private $dry = false; |
|
98 | 98 | |
99 | - public function __construct($name = '') { |
|
100 | - parent::__construct($name); |
|
101 | - $this->requiresLayout = true; |
|
102 | - } |
|
99 | + public function __construct($name = '') { |
|
100 | + parent::__construct($name); |
|
101 | + $this->requiresLayout = true; |
|
102 | + } |
|
103 | 103 | |
104 | - public function __destruct() { |
|
105 | - $this->close(); |
|
106 | - } |
|
104 | + public function __destruct() { |
|
105 | + $this->close(); |
|
106 | + } |
|
107 | 107 | |
108 | - public function setDry($dry) { |
|
109 | - $this->dry = $dry; |
|
110 | - } |
|
108 | + public function setDry($dry) { |
|
109 | + $this->dry = $dry; |
|
110 | + } |
|
111 | 111 | |
112 | - /** |
|
113 | - * Set the ident of the syslog message. |
|
114 | - * |
|
115 | - * @param string Ident |
|
116 | - */ |
|
117 | - public function setIdent($ident) { |
|
118 | - $this->_ident = $ident; |
|
119 | - } |
|
112 | + /** |
|
113 | + * Set the ident of the syslog message. |
|
114 | + * |
|
115 | + * @param string Ident |
|
116 | + */ |
|
117 | + public function setIdent($ident) { |
|
118 | + $this->_ident = $ident; |
|
119 | + } |
|
120 | 120 | |
121 | - /** |
|
122 | - * Set the priority value for the syslog message. |
|
123 | - * |
|
124 | - * @param const int Priority |
|
125 | - */ |
|
126 | - public function setPriority($priority) { |
|
127 | - $this->_priority = $priority; |
|
128 | - } |
|
121 | + /** |
|
122 | + * Set the priority value for the syslog message. |
|
123 | + * |
|
124 | + * @param const int Priority |
|
125 | + */ |
|
126 | + public function setPriority($priority) { |
|
127 | + $this->_priority = $priority; |
|
128 | + } |
|
129 | 129 | |
130 | 130 | |
131 | - /** |
|
132 | - * Set the facility value for the syslog message. |
|
133 | - * |
|
134 | - * @param const int Facility |
|
135 | - */ |
|
136 | - public function setFacility($facility) { |
|
137 | - $this->_facility = $facility; |
|
138 | - } |
|
131 | + /** |
|
132 | + * Set the facility value for the syslog message. |
|
133 | + * |
|
134 | + * @param const int Facility |
|
135 | + */ |
|
136 | + public function setFacility($facility) { |
|
137 | + $this->_facility = $facility; |
|
138 | + } |
|
139 | 139 | |
140 | - /** |
|
141 | - * If the priority of the message to be sent can be defined by a value in the properties-file, |
|
142 | - * set parameter value to "true". |
|
143 | - * |
|
144 | - * @param bool Override priority |
|
145 | - */ |
|
146 | - public function setOverridePriority($overridePriority) { |
|
147 | - $this->_overridePriority = $overridePriority; |
|
148 | - } |
|
140 | + /** |
|
141 | + * If the priority of the message to be sent can be defined by a value in the properties-file, |
|
142 | + * set parameter value to "true". |
|
143 | + * |
|
144 | + * @param bool Override priority |
|
145 | + */ |
|
146 | + public function setOverridePriority($overridePriority) { |
|
147 | + $this->_overridePriority = $overridePriority; |
|
148 | + } |
|
149 | 149 | |
150 | - /** |
|
151 | - * Set the option value for the syslog message. |
|
152 | - * This value is used as a parameter for php openlog() |
|
153 | - * and passed on to the syslog daemon. |
|
154 | - * |
|
155 | - * @param string $option |
|
156 | - */ |
|
157 | - public function setOption($option) { |
|
158 | - $this->_option = $option; |
|
159 | - } |
|
150 | + /** |
|
151 | + * Set the option value for the syslog message. |
|
152 | + * This value is used as a parameter for php openlog() |
|
153 | + * and passed on to the syslog daemon. |
|
154 | + * |
|
155 | + * @param string $option |
|
156 | + */ |
|
157 | + public function setOption($option) { |
|
158 | + $this->_option = $option; |
|
159 | + } |
|
160 | 160 | |
161 | - public function activateOptions() { |
|
162 | - // Deprecated as of 5.3 and removed in 6.0 |
|
163 | - // define_syslog_variables(); |
|
164 | - $this->closed = false; |
|
165 | - } |
|
161 | + public function activateOptions() { |
|
162 | + // Deprecated as of 5.3 and removed in 6.0 |
|
163 | + // define_syslog_variables(); |
|
164 | + $this->closed = false; |
|
165 | + } |
|
166 | 166 | |
167 | - public function close() { |
|
168 | - if($this->closed != true) { |
|
169 | - closelog(); |
|
170 | - $this->closed = true; |
|
171 | - } |
|
172 | - } |
|
167 | + public function close() { |
|
168 | + if($this->closed != true) { |
|
169 | + closelog(); |
|
170 | + $this->closed = true; |
|
171 | + } |
|
172 | + } |
|
173 | 173 | |
174 | - public function append(LoggerLoggingEvent $event) { |
|
175 | - if($this->_option == NULL){ |
|
176 | - $this->_option = LOG_PID | LOG_CONS; |
|
177 | - } |
|
174 | + public function append(LoggerLoggingEvent $event) { |
|
175 | + if($this->_option == NULL){ |
|
176 | + $this->_option = LOG_PID | LOG_CONS; |
|
177 | + } |
|
178 | 178 | |
179 | - $level = $event->getLevel(); |
|
180 | - if($this->layout === null) { |
|
181 | - $message = $event->getRenderedMessage(); |
|
182 | - } else { |
|
183 | - $message = $this->layout->format($event); |
|
184 | - } |
|
179 | + $level = $event->getLevel(); |
|
180 | + if($this->layout === null) { |
|
181 | + $message = $event->getRenderedMessage(); |
|
182 | + } else { |
|
183 | + $message = $this->layout->format($event); |
|
184 | + } |
|
185 | 185 | |
186 | - // If the priority of a syslog message can be overridden by a value defined in the properties-file, |
|
187 | - // use that value, else use the one that is defined in the code. |
|
188 | - if(!$this->dry) { |
|
189 | - // Attach the process ID to the message, use the facility defined in the .properties-file |
|
190 | - openlog($this->_ident, $this->_option, $this->_facility); |
|
186 | + // If the priority of a syslog message can be overridden by a value defined in the properties-file, |
|
187 | + // use that value, else use the one that is defined in the code. |
|
188 | + if(!$this->dry) { |
|
189 | + // Attach the process ID to the message, use the facility defined in the .properties-file |
|
190 | + openlog($this->_ident, $this->_option, $this->_facility); |
|
191 | 191 | |
192 | - if($this->_overridePriority) { |
|
193 | - syslog($this->_priority, $message); |
|
194 | - } else { |
|
195 | - if($level->isGreaterOrEqual(LoggerLevel::getLevelFatal())) { |
|
196 | - syslog(LOG_ALERT, $message); |
|
197 | - } else if ($level->isGreaterOrEqual(LoggerLevel::getLevelError())) { |
|
198 | - syslog(LOG_ERR, $message); |
|
199 | - } else if ($level->isGreaterOrEqual(LoggerLevel::getLevelWarn())) { |
|
200 | - syslog(LOG_WARNING, $message); |
|
201 | - } else if ($level->isGreaterOrEqual(LoggerLevel::getLevelInfo())) { |
|
202 | - syslog(LOG_INFO, $message); |
|
203 | - } else if ($level->isGreaterOrEqual(LoggerLevel::getLevelDebug())) { |
|
204 | - syslog(LOG_DEBUG, $message); |
|
205 | - } |
|
206 | - } |
|
207 | - closelog(); |
|
208 | - } else { |
|
209 | - echo "DRY MODE OF SYSLOG APPENDER: ".$message; |
|
210 | - } |
|
211 | - } |
|
192 | + if($this->_overridePriority) { |
|
193 | + syslog($this->_priority, $message); |
|
194 | + } else { |
|
195 | + if($level->isGreaterOrEqual(LoggerLevel::getLevelFatal())) { |
|
196 | + syslog(LOG_ALERT, $message); |
|
197 | + } else if ($level->isGreaterOrEqual(LoggerLevel::getLevelError())) { |
|
198 | + syslog(LOG_ERR, $message); |
|
199 | + } else if ($level->isGreaterOrEqual(LoggerLevel::getLevelWarn())) { |
|
200 | + syslog(LOG_WARNING, $message); |
|
201 | + } else if ($level->isGreaterOrEqual(LoggerLevel::getLevelInfo())) { |
|
202 | + syslog(LOG_INFO, $message); |
|
203 | + } else if ($level->isGreaterOrEqual(LoggerLevel::getLevelDebug())) { |
|
204 | + syslog(LOG_DEBUG, $message); |
|
205 | + } |
|
206 | + } |
|
207 | + closelog(); |
|
208 | + } else { |
|
209 | + echo "DRY MODE OF SYSLOG APPENDER: ".$message; |
|
210 | + } |
|
211 | + } |
|
212 | 212 | } |