summaryrefslogtreecommitdiff
path: root/framework/Util/TPropelLogRoute.php
blob: 2ebbc56122d120c80775b753f04a0103c335dc98 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
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();
		}
	}
}
?>