[pLog-svn] r2417 - in plog/branches/plog-1.1-daochanges:
class/logger class/logger/layout config
oscar at devel.plogworld.net
oscar at devel.plogworld.net
Wed Aug 24 21:12:35 GMT 2005
Author: oscar
Date: 2005-08-24 21:12:34 +0000 (Wed, 24 Aug 2005)
New Revision: 2417
Modified:
plog/branches/plog-1.1-daochanges/class/logger/LogUtil.php
plog/branches/plog-1.1-daochanges/class/logger/layout/patternlayout.class.php
plog/branches/plog-1.1-daochanges/config/logging.properties.php
Log:
via the %t modifier, loggers are now able to log a full stack trace of the calling method
Modified: plog/branches/plog-1.1-daochanges/class/logger/LogUtil.php
===================================================================
--- plog/branches/plog-1.1-daochanges/class/logger/LogUtil.php 2005-08-20 12:23:56 UTC (rev 2416)
+++ plog/branches/plog-1.1-daochanges/class/logger/LogUtil.php 2005-08-24 21:12:34 UTC (rev 2417)
@@ -105,6 +105,7 @@
$dumpedvariable = ob_get_contents();
ob_end_clean();
return $dumpedvariable;
- }
+ }
+
}
?>
Modified: plog/branches/plog-1.1-daochanges/class/logger/layout/patternlayout.class.php
===================================================================
--- plog/branches/plog-1.1-daochanges/class/logger/layout/patternlayout.class.php 2005-08-20 12:23:56 UTC (rev 2416)
+++ plog/branches/plog-1.1-daochanges/class/logger/layout/patternlayout.class.php 2005-08-24 21:12:34 UTC (rev 2417)
@@ -1,7 +1,8 @@
<?php
- include_once(PLOG_CLASS_PATH."class/logger/layout/layout.class.php");
+ include_once( PLOG_CLASS_PATH."class/logger/layout/layout.class.php" );
+
/**
* PatternLayout allows a completely customizable layout that uses a conversion
* pattern for formatting.
@@ -47,6 +48,44 @@
return( $value );
}
+
+ /**
+ * @static
+ * @returns returns an array containing information about the stack, or an empty array
+ * if such information is not available.
+ * per line
+ */
+ function getStackTrace()
+ {
+ if( function_exists("debug_backtrace"))
+ return( debug_backtrace());
+ else
+ return( Array());
+ }
+
+ /**
+ * @static
+ * @returns returns an string containing a full stack trace, one step of the stack
+ * per line
+ */
+ function printableStackTrace()
+ {
+ $info = PatternLayout::getStackTrace();
+ $result = "";
+ foreach( $info as $trace ) {
+ if( ($trace["function"] != "printStackTrace") && ($trace["file"] != __FILE__ )) {
+ $result .= $trace["file"];
+ $result .= "(".$trace["line"]."): ";
+ if( isset( $trace["class"] )) {
+ if( $trace["class"] != "" )
+ $result .= $trace["class"].".";
+ }
+ $result .= $trace["function"];
+ $result .= "\n";
+ }
+ }
+ return( $result );
+ }
/**
* Format a log message.
@@ -69,6 +108,7 @@
* <li><b>%t</b> - a horizontal tab</li>
* <li><b>%T</b> - a unix timestamp (seconds since January
* 1st, 1970)</li>
+ * <li><b>%S</b> - the full stack trace, if available</li>
* </ul>
*
* @param Message A Message instance.
@@ -89,9 +129,9 @@
$pattern = str_replace( "%r", "\r", $pattern );
$pattern = str_replace( "%t", "\t", $pattern );
$pattern = str_replace( "%T", time(), $pattern );
+ $pattern = str_replace( "%S", PatternLayout::printableStackTrace(), $pattern );
return( $pattern );
}
}
-
?>
\ No newline at end of file
Modified: plog/branches/plog-1.1-daochanges/config/logging.properties.php
===================================================================
--- plog/branches/plog-1.1-daochanges/config/logging.properties.php 2005-08-20 12:23:56 UTC (rev 2416)
+++ plog/branches/plog-1.1-daochanges/config/logging.properties.php 2005-08-24 21:12:34 UTC (rev 2417)
@@ -14,10 +14,10 @@
// debug output sent to debug.log by default.
$config["debug"] = Array(
- "layout" => "%d %N - [%f:%l (%c:%F)] %m%n",
+ "layout" => "%S %d %N - [%f:%l (%c:%F)] %m%n",
"appender" => "file",
"file" => "tmp/debug.log",
- "prio" => "info"
+ "prio" => "info"
);
#
# this logger is the only one enabled by default
@@ -42,4 +42,4 @@
"prio" => "debug"
);
-?>
+?>
\ No newline at end of file
More information about the pLog-svn
mailing list