summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorxue <>2006-04-03 13:05:22 +0000
committerxue <>2006-04-03 13:05:22 +0000
commit940a53f12d6aa0984608b9b59d94723658dfd409 (patch)
treec708782619055094d38c536ddc733c0c3167ce3a
parent1e0efb03df0ad2309a3e3bef64c6268a292373b9 (diff)
Added TPropelLogRoute.
-rw-r--r--.gitattributes1
-rw-r--r--HISTORY1
-rw-r--r--framework/Util/TLogRouter.php8
-rw-r--r--framework/Util/TPropelLogRoute.php95
4 files changed, 104 insertions, 1 deletions
diff --git a/.gitattributes b/.gitattributes
index d00acc93..e3cb02e2 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -671,6 +671,7 @@ framework/Util/TDataFieldAccessor.php -text
framework/Util/TLogRouter.php -text
framework/Util/TLogger.php -text
framework/Util/TParameterModule.php -text
+framework/Util/TPropelLogRoute.php -text
framework/Util/TSimpleDateFormatter.php -text
framework/Util/TVarDumper.php -text
framework/Web/Javascripts/TJSON.php -text
diff --git a/HISTORY b/HISTORY
index b41eac85..3b18476d 100644
--- a/HISTORY
+++ b/HISTORY
@@ -26,6 +26,7 @@ NEW: TWizard control (Qiang)
NEW: TVarDumper and PradoBase::varDump() (Qiang)
NEW: TComponentReflection (Qiang)
NEW: TParameterModule (Qiang)
+NEW: TPropelLogRoute (Jason)
Version 3.0b March 6, 2006
==========================
diff --git a/framework/Util/TLogRouter.php b/framework/Util/TLogRouter.php
index bdad8649..06d70b1e 100644
--- a/framework/Util/TLogRouter.php
+++ b/framework/Util/TLogRouter.php
@@ -292,7 +292,13 @@ abstract class TLogRoute extends TApplicationComponent
/**
* Processes log messages and sends them to specific destination.
* Derived child classes must implement this method.
- * @param array list of messages. Each array element is a (formatted) message string.
+ * @param array list of messages. Each array elements represents one message
+ * with the following structure:
+ * array(
+ * [0] => message
+ * [1] => level
+ * [2] => category
+ * [3] => timestamp);
*/
abstract protected function processLogs($logs);
}
diff --git a/framework/Util/TPropelLogRoute.php b/framework/Util/TPropelLogRoute.php
new file mode 100644
index 00000000..2ebbc561
--- /dev/null
+++ b/framework/Util/TPropelLogRoute.php
@@ -0,0 +1,95 @@
+<?php
+/**
+ * TLogger class file
+ *
+ * @author Jason Ragsdale <jrags@jasrags.net>
+ * @link http://www.pradosoft.com/
+ * @copyright Copyright &copy; 2006 PradoSoft
+ * @license http://www.pradosoft.com/license/
+ * @version $Revision: $ $Date: $
+ * @package System.Util
+ */
+
+/**
+ * TPropelLogRoute class.
+ *
+ * TPropelLogRoute saves selected log messages into a Propel database.
+ * The name of the Propel database object used to represent each message
+ * is specified by {@link setPropelObjectName PropelObjectName}, which defaults
+ * to 'PradoLog'.
+ *
+ * The schema of the Propel object must be as follows (the table name can be
+ * changed to the value of {@link getPropelObjectName PropelObjectName}.
+ * <code>
+ * <table name="PradoLog">
+ * <column
+ * name="ID"
+ * required="true"
+ * primaryKey="true"
+ * autoIncrement="true"
+ * type="INTEGER" />
+ * <column
+ * name="Category"
+ * required="true"
+ * type="VARCHAR"
+ * size="255" />
+ * <column
+ * name="Level"
+ * required="true"
+ * type="VARCHAR"
+ * size="255" />
+ * <column
+ * name="Message"
+ * required="true"
+ * type="LONGVARCHAR"
+ * size="2048" />
+ * <column
+ * name="Time"
+ * type="TIMESTAMP"/>
+ * </table>
+ * </code>
+ *
+ * @author Jason Ragsdale <jrags@jasrags.net>
+ * @version $Revision: $ $Date: $
+ * @package System.Util
+ * @since 3.0
+ */
+class TPropelLogRoute extends TLogRoute
+{
+ private $_className='PradoLog';
+
+ /**
+ * @return string the name of the Prople object used to save each log message. Defaults to 'PradoLog'.
+ */
+ public function getPropelObjectName()
+ {
+ return $this->_className;
+ }
+
+ /**
+ * @param string the name of the Prople object used to save each log message. The name can be in namespace format.
+ */
+ public function setPropelObjectName($value)
+ {
+ $this->_className=$value;
+ }
+
+ /**
+ * Saves log messages to the Propel database object.
+ *
+ * @param array $logs
+ */
+ protected function processLogs($logs)
+ {
+ foreach($logs as $log)
+ {
+ $pradoLog=Prado::createComponent($this->_className);
+ $pradoLog->setMessage($log[0]);
+ $pradoLog->setLevel($this->getLevelName($log[1]));
+ $pradoLog->setCategory($log[2]);
+ $pradoLog->setTime($log[3]);
+ $pradoLog->save();
+ }
+ }
+}
+?> \ No newline at end of file