Updated Branches: refs/heads/develop 233373e3b -> 382cf2409
Cleaned up phpdoc for layouts. Added missing accessors. Project: http://git-wip-us.apache.org/repos/asf/logging-log4php/repo Commit: http://git-wip-us.apache.org/repos/asf/logging-log4php/commit/382cf240 Tree: http://git-wip-us.apache.org/repos/asf/logging-log4php/tree/382cf240 Diff: http://git-wip-us.apache.org/repos/asf/logging-log4php/diff/382cf240 Branch: refs/heads/develop Commit: 382cf240982e6d3a6da13e8ab861448e0e0720b4 Parents: 233373e Author: Ivan Habunek <[email protected]> Authored: Wed Dec 26 11:41:19 2012 +0100 Committer: Ivan Habunek <[email protected]> Committed: Wed Dec 26 11:41:19 2012 +0100 ---------------------------------------------------------------------- src/main/php/layouts/LoggerLayoutHtml.php | 70 +++-------- src/main/php/layouts/LoggerLayoutPattern.php | 22 ++-- src/main/php/layouts/LoggerLayoutSerialized.php | 29 +++-- src/main/php/layouts/LoggerLayoutSimple.php | 2 - src/main/php/layouts/LoggerLayoutTTCC.php | 116 ++++++++---------- src/main/php/layouts/LoggerLayoutXml.php | 73 +++-------- 6 files changed, 121 insertions(+), 191 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/382cf240/src/main/php/layouts/LoggerLayoutHtml.php ---------------------------------------------------------------------- diff --git a/src/main/php/layouts/LoggerLayoutHtml.php b/src/main/php/layouts/LoggerLayoutHtml.php index 371b143..450d298 100644 --- a/src/main/php/layouts/LoggerLayoutHtml.php +++ b/src/main/php/layouts/LoggerLayoutHtml.php @@ -14,93 +14,61 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * - * @package log4php */ /** - * This layout outputs events in a HTML table. + * This layout outputs events in a HTML document. * - * Configurable parameters for this layout are: - * - * - title - * - locationInfo - * - * An example for this layout: - * - * {@example ../../examples/php/layout_html.php 19}<br> + * ## Configurable parameters: ## * - * The corresponding XML file: - * - * {@example ../../examples/resources/layout_html.properties 18} - * - * The above will print a HTML table that looks, converted back to plain text, like the following:<br> - * <pre> - * Log session start time Wed Sep 9 00:11:30 2009 - * - * Time Thread Level Category Message - * 0 8318 INFO root Hello World! - * </pre> + * - **title** - the HTML <title> + * - **locationInfo** - If set to true, logs the file name and line number at + * which the log statement originated. Slightly slower, defaults to false. * * @package log4php * @subpackage layouts + * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0 + * @link http://logging.apache.org/log4php/docs/layouts/html.html Layout documentation */ class LoggerLayoutHtml extends LoggerLayout { /** - * The <b>LocationInfo</b> option takes a boolean value. By - * default, it is set to false which means there will be no location - * information output by this layout. If the the option is set to - * true, then the file name and line number of the statement - * at the origin of the log statement will be output. - * - * <p>If you are embedding this layout within a {@link LoggerAppenderMail} - * or a {@link LoggerAppenderMailEvent} then make sure to set the - * <b>LocationInfo</b> option of that appender as well. + * Whether to log location information (file and line number). * @var boolean */ protected $locationInfo = false; - /** - * The <b>Title</b> option takes a String value. This option sets the - * document title of the generated HTML document. - * Defaults to 'Log4php Log Messages'. + /** + * The title of the HTML document. * @var string */ protected $title = "Log4php Log Messages"; /** - * The <b>LocationInfo</b> option takes a boolean value. By - * default, it is set to false which means there will be no location - * information output by this layout. If the the option is set to - * true, then the file name and line number of the statement - * at the origin of the log statement will be output. - * - * <p>If you are embedding this layout within a {@link LoggerAppenderMail} - * or a {@link LoggerAppenderMailEvent} then make sure to set the - * <b>LocationInfo</b> option of that appender as well. + * Sets the 'locationInfo' parameter. + * @param boolean $locationInfo */ - public function setLocationInfo($flag) { - $this->setBoolean('locationInfo', $flag); + public function setLocationInfo($locationInfo) { + $this->setBoolean('locationInfo', $locationInfo); } /** - * Returns the current value of the <b>LocationInfo</b> option. + * Returns the value of the 'locationInfo' parameter. */ public function getLocationInfo() { return $this->locationInfo; } /** - * The <b>Title</b> option takes a String value. This option sets the - * document title of the generated HTML document. - * Defaults to 'Log4php Log Messages'. + * Sets the 'title' parameter. + * @param string $title */ public function setTitle($title) { $this->setString('title', $title); } /** - * @return string Returns the current value of the <b>Title</b> option. + * Returns the value of the 'title' parameter. + * @return string */ public function getTitle() { return $this->title; http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/382cf240/src/main/php/layouts/LoggerLayoutPattern.php ---------------------------------------------------------------------- diff --git a/src/main/php/layouts/LoggerLayoutPattern.php b/src/main/php/layouts/LoggerLayoutPattern.php index 92688b7..cf34d05 100644 --- a/src/main/php/layouts/LoggerLayoutPattern.php +++ b/src/main/php/layouts/LoggerLayoutPattern.php @@ -14,20 +14,20 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * - * @package log4php */ /** * A flexible layout configurable with a pattern string. * - * Configurable parameters: + * ## Configurable parameters: ## * - * * converionPattern - A string which controls the formatting of logging + * - **converionPattern** - A string which controls the formatting of logging * events. See docs for full specification. * * @package log4php * @subpackage layouts + * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0 + * @link http://logging.apache.org/log4php/docs/layouts/pattern.html Layout documentation */ class LoggerLayoutPattern extends LoggerLayout { @@ -130,16 +130,22 @@ class LoggerLayoutPattern extends LoggerLayout { } /** - * Sets the conversionPattern option. This is the string which - * controls formatting and consists of a mix of literal content and - * conversion specifiers. - * @param array $conversionPattern + * Sets the 'conversionPattern' parameter. + * @param string $conversionPattern */ public function setConversionPattern($conversionPattern) { $this->pattern = $conversionPattern; } /** + * Returns the value of the 'conversionPattern' parameter. + * @return string + */ + public function getConversionPattern() { + return $this->pattern; + } + + /** * Processes the conversion pattern and creates a corresponding chain of * pattern converters which will be used to format logging events. */ http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/382cf240/src/main/php/layouts/LoggerLayoutSerialized.php ---------------------------------------------------------------------- diff --git a/src/main/php/layouts/LoggerLayoutSerialized.php b/src/main/php/layouts/LoggerLayoutSerialized.php index 3bd4b58..2d3d0a5 100644 --- a/src/main/php/layouts/LoggerLayoutSerialized.php +++ b/src/main/php/layouts/LoggerLayoutSerialized.php @@ -14,32 +14,39 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * - * @package log4php */ /** * Layout which formats the events using PHP's serialize() function. * - * Available options: - * - locationInfo - If set to true, the event's location information will also - * be serialized (slow, defaults to false). + * ## Configurable parameters: ## + * + * - **locationInfo** - If set to true, adds the file name and line number at + * which the log statement originated. Slightly slower, defaults to false. * * @package log4php * @subpackage layouts * @since 2.2 + * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0 + * @link http://logging.apache.org/log4php/docs/layouts/serialized.html Layout documentation */ class LoggerLayoutSerialized extends LoggerLayout { - /** Whether to include the event's location information (slow). */ + /** Whether to include the event's location information (slower). */ protected $locationInfo = false; - /** Sets the location information flag. */ - public function setLocationInfo($value) { - $this->setBoolean('locationInfo', $value); + /** + * Sets the 'locationInfo' parameter. + * @param boolean $locationInfo + */ + public function setLocationInfo($locationInfo) { + $this->setBoolean('locationInfo', $locationInfo); } - - /** Returns the location information flag. */ + + /** + * Returns the value of the 'locationInfo' parameter. + * @return boolean + */ public function getLocationInfo() { return $this->locationInfo; } http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/382cf240/src/main/php/layouts/LoggerLayoutSimple.php ---------------------------------------------------------------------- diff --git a/src/main/php/layouts/LoggerLayoutSimple.php b/src/main/php/layouts/LoggerLayoutSimple.php index 7854e7f..a13756a 100644 --- a/src/main/php/layouts/LoggerLayoutSimple.php +++ b/src/main/php/layouts/LoggerLayoutSimple.php @@ -14,8 +14,6 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * - * @package log4php */ /** http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/382cf240/src/main/php/layouts/LoggerLayoutTTCC.php ---------------------------------------------------------------------- diff --git a/src/main/php/layouts/LoggerLayoutTTCC.php b/src/main/php/layouts/LoggerLayoutTTCC.php index 7a96957..7e34914 100644 --- a/src/main/php/layouts/LoggerLayoutTTCC.php +++ b/src/main/php/layouts/LoggerLayoutTTCC.php @@ -14,151 +14,139 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * - * @package log4php */ /** - * TTCC layout format consists of <b>t</b>ime, <b>t</b>hread, <b>c</b>ategory and nested - * diagnostic <b>c</b>ontext information, hence the name. + * TTCC layout format consists of: + * - **t**ime, + * - **t**hread, + * - **c**ategory and + * - nested diagnostic **c**ontext information * - * <p>Each of the four fields can be individually enabled or - * disabled. The time format depends on the <b>DateFormat</b> used.</p> - * - * <p>If no dateFormat is specified it defaults to '%c'. - * See php {@link PHP_MANUAL#date} function for details.</p> + * Each of the four fields can be individually enabled or disabled. The time + * format depends on the **dateFormat** used. If no dateFormat is specified + * it defaults to '%c'. See php {@link PHP_MANUAL#date} function for details. * - * Configurable parameters for this layout are: - * - {@link $threadPrinting} (true|false) enable/disable pid reporting. - * - {@link $categoryPrefixing} (true|false) enable/disable logger category reporting. - * - {@link $contextPrinting} (true|false) enable/disable NDC reporting. - * - {@link $microSecondsPrinting} (true|false) enable/disable micro seconds reporting in timestamp. - * - {@link $dateFormat} (string) set date format. See php {@link PHP_MANUAL#date} function for details. - * - * An example how to use this layout: - * - * {@example ../../examples/php/layout_ttcc.php 19}<br> + * ## Configurable parameters: ## * - * {@example ../../examples/resources/layout_ttcc.properties 18}<br> - * - * The above would print:<br> - * <samp>02:28 [13714] INFO root - Hello World!</samp> + * - **$threadPrinting** (boolean) enable/disable pid reporting. + * - **$categoryPrefixing** (boolean) enable/disable logger category reporting. + * - **$contextPrinting** (boolean) enable/disable NDC reporting. + * - **$microSecondsPrinting** (boolean) enable/disable micro seconds reporting + * in timestamp. + * - **$dateFormat** (string) sets the date format. * * @package log4php * @subpackage layouts - * + * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0 + * @link http://logging.apache.org/log4php/docs/layouts/ttcc.html Layout documentation * @deprecated LoggerLayout TTCC is deprecated and will be removed in a future release. Please use * LoggerLayoutPattern instead. */ class LoggerLayoutTTCC extends LoggerLayout { - - // Internal representation of options - protected $threadPrinting = true; + + /** Whether to output the process ID. */ + protected $threadPrinting = true; + + /** Whether to output the category name. */ protected $categoryPrefixing = true; + + /** Whether to output the nested diagnostic context. */ protected $contextPrinting = true; + + /** Whether to include microseconds in the timestmap. */ protected $microSecondsPrinting = true; - /** - * @var string date format. See {@link PHP_MANUAL#strftime} for details - */ + /** The date format */ protected $dateFormat = '%c'; - /** - * Constructor - * - * @param string date format - * @see dateFormat - */ - public function __construct($dateFormat = '') { + public function __construct($dateFormat = null) { $this->warn("LoggerLayout TTCC is deprecated and will be removed in a future release. Please use LoggerLayoutPattern instead."); - if (!empty($dateFormat)) { + if (isset($dateFormat)) { $this->dateFormat = $dateFormat; } - return; } /** - * The <b>ThreadPrinting</b> option specifies whether the name of the - * current thread is part of log output or not. This is true by default. + * Sets the 'threadPrinting' parameter. + * @param boolean $threadPrinting */ public function setThreadPrinting($threadPrinting) { $this->setBoolean('threadPrinting', $threadPrinting); } /** - * @return boolean Returns value of the <b>ThreadPrinting</b> option. + * Returns the value of the 'threadPrinting' parameter. + * @return boolean */ public function getThreadPrinting() { return $this->threadPrinting; } /** - * The <b>CategoryPrefixing</b> option specifies whether {@link Category} - * name is part of log output or not. This is true by default. + * Sets the 'categoryPrefixing' parameter. + * @param boolean $categoryPrefixing */ public function setCategoryPrefixing($categoryPrefixing) { $this->setBoolean('categoryPrefixing', $categoryPrefixing); } /** - * @return boolean Returns value of the <b>CategoryPrefixing</b> option. + * Returns the value of the 'categoryPrefixing' parameter. + * @return boolean */ public function getCategoryPrefixing() { return $this->categoryPrefixing; } /** - * The <b>ContextPrinting</b> option specifies log output will include - * the nested context information belonging to the current thread. - * This is true by default. + * Sets the 'contextPrinting' parameter. + * @param boolean $contextPrinting */ public function setContextPrinting($contextPrinting) { $this->setBoolean('contextPrinting', $contextPrinting); } /** - * @return boolean Returns value of the <b>ContextPrinting</b> option. + * Returns the value of the 'contextPrinting' parameter. + * @return boolean */ public function getContextPrinting() { return $this->contextPrinting; } /** - * The <b>MicroSecondsPrinting</b> option specifies if microseconds infos - * should be printed at the end of timestamp. - * This is true by default. + * Sets the 'microSecondsPrinting' parameter. + * @param boolean $microSecondsPrinting */ public function setMicroSecondsPrinting($microSecondsPrinting) { $this->setBoolean('microSecondsPrinting', $microSecondsPrinting); } /** - * @return boolean Returns value of the <b>MicroSecondsPrinting</b> option. + * Returns the value of the 'microSecondsPrinting' parameter. + * @return boolean */ public function getMicroSecondsPrinting() { return $this->microSecondsPrinting; } - + /** + * Sets the 'dateFormat' parameter. + * @param string $dateFormat + */ public function setDateFormat($dateFormat) { $this->setString('dateFormat', $dateFormat); } /** + * Returns the value of the 'dateFormat' parameter. * @return string */ public function getDateFormat() { return $this->dateFormat; } - /** - * In addition to the level of the statement and message, the - * returned string includes time, thread, category. - * <p>Time, thread, category are printed depending on options. - * - * @param LoggerLoggingEvent $event - * @return string - */ public function format(LoggerLoggingEvent $event) { $timeStamp = (float)$event->getTimeStamp(); $format = strftime($this->dateFormat, (int)$timeStamp); @@ -193,8 +181,4 @@ class LoggerLayoutTTCC extends LoggerLayout { return $format; } - - public function ignoresThrowable() { - return true; - } } http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/382cf240/src/main/php/layouts/LoggerLayoutXml.php ---------------------------------------------------------------------- diff --git a/src/main/php/layouts/LoggerLayoutXml.php b/src/main/php/layouts/LoggerLayoutXml.php index 66f2950..b6719a3 100644 --- a/src/main/php/layouts/LoggerLayoutXml.php +++ b/src/main/php/layouts/LoggerLayoutXml.php @@ -14,43 +14,27 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * - * @package log4php */ /** * The output of the LoggerXmlLayout consists of a series of log4php:event elements. * - * Configurable parameters: - * - {@link $locationInfo} - If set to true then the file name and line number - * of the origin of the log statement will be included in output. - * - {@link $log4jNamespace} - If set to true then log4j namespace will be used + * ## Configurable parameters: ## + * + * - **locationInfo** - If set to true, adds the file name and line number at + * which the log statement originated. Slightly slower, defaults to false. + * - **log4jNamespace** - If set to true then log4j namespace will be used * instead of log4php namespace. This can be usefull when using log viewers * which can only parse the log4j namespace such as Apache Chainsaw. * - * <p>It does not output a complete well-formed XML file. - * The output is designed to be included as an external entity in a separate file to form - * a correct XML file.</p> - * - * Example: - * - * {@example ../../examples/php/layout_xml.php 19}<br> + * It does not output a complete well-formed XML file. The output is designed + * to be included as an external entity in a separate file to form a correct + * XML file. * - * {@example ../../examples/resources/layout_xml.properties 18}<br> - * - * The above would print: - * - * <pre> - * <log4php:eventSet xmlns:log4php="http://logging.apache.org/log4php/" version="0.3" includesLocationInfo="true"> - * <log4php:event logger="root" level="INFO" thread="13802" timestamp="1252456226491"> - * <log4php:message><![CDATA[Hello World!]]></log4php:message> - * <log4php:locationInfo class="main" file="examples/php/layout_xml.php" line="6" method="main" /> - * </log4php:event> - * </log4php:eventSet> - * </pre> - * * @package log4php * @subpackage layouts + * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0 + * @link http://logging.apache.org/log4php/docs/layouts/xml.html Layout documentation */ class LoggerLayoutXml extends LoggerLayout { const LOG4J_NS_PREFIX ='log4j'; @@ -65,15 +49,13 @@ class LoggerLayoutXml extends LoggerLayout { const CDATA_EMBEDDED_END = ']]>]]><