diff options
author | wei <> | 2006-01-05 01:23:24 +0000 |
---|---|---|
committer | wei <> | 2006-01-05 01:23:24 +0000 |
commit | 0f7ba713001879bb7cfd0ca3a84c7683ef4ce212 (patch) | |
tree | 3b81e17b4d64db47fdc849af1395a0f3c3e1350a | |
parent | 77750ab4cc4c0055a29352334a9357d74e3957d3 (diff) |
adding ILog interface and TInternalLogger
-rw-r--r-- | .gitattributes | 1 | ||||
-rw-r--r-- | framework/Log/ILog.php | 74 |
2 files changed, 75 insertions, 0 deletions
diff --git a/.gitattributes b/.gitattributes index 8c756097..3da00821 100644 --- a/.gitattributes +++ b/.gitattributes @@ -143,6 +143,7 @@ framework/Log/EventLog/structs/log_filter.php -text framework/Log/EventLog/writers/writer_database.php -text framework/Log/EventLog/writers/writer_file.php -text framework/Log/EventLog/writers/writer_unix_file.php -text +framework/Log/ILog.php -text framework/Log/TEventLog.php -text framework/Log/TLogManager.php -text framework/Security/TAuthManager.php -text diff --git a/framework/Log/ILog.php b/framework/Log/ILog.php new file mode 100644 index 00000000..712f8396 --- /dev/null +++ b/framework/Log/ILog.php @@ -0,0 +1,74 @@ +<?php
+
+interface ILog
+{
+ public function info($msg, $source='Prado', $category='core');
+ public function debug($msg, $source='Prado', $category='core');
+ public function notice($msg, $source='Prado', $category='core');
+ public function warn($msg, $source='Prado', $category='core');
+ public function error($msg, $source='Prado', $category='core');
+ public function fatal($msg, $source='Prado', $category='core');
+}
+
+require_once(dirname(__FILE__).'/EventLog/log.php');
+
+/**
+ * ${classname}
+ *
+ * ${description}
+ *
+ * @author Wei Zhuo<weizhuo[at]gmail[dot]com>
+ * @version $Revision: 1.66 $ $Date: ${DATE} ${TIME} $
+ * @package ${package}
+ */
+class TInternalLogger
+{
+ public $entries = array();
+
+ public function info($msg, $source='Prado', $category='core')
+ {
+ $this->log($msg, ezcLog::INFO,
+ array('source'=>$source, 'category'=>$category));
+ }
+ public function debug($msg, $source='Prado', $category='core')
+ {
+ $this->log($msg, ezcLog::DEBUG,
+ array('source'=>$source, 'category'=>$category));
+ }
+ public function notice($msg, $source='Prado', $category='core')
+ {
+ $this->log($msg, ezcLog::NOTICE,
+ array('source'=>$source, 'category'=>$category));
+ }
+
+ public function warn($msg, $source='Prado', $category='core')
+ {
+ $this->log($msg, ezcLog::WARNING,
+ array('source'=>$source, 'category'=>$category));
+ }
+
+ public function error($msg, $source='Prado', $category='core')
+ {
+ $this->log($msg, ezcLog::ERROR,
+ array('source'=>$source, 'category'=>$category));
+ }
+
+ public function fatal($msg, $source='Prado', $category='core')
+ {
+ $this->log($msg, ezcLog::FATAL,
+ array('source'=>$source, 'category'=>$category));
+ }
+
+ protected function log($msg, $type, $info)
+ {
+ if($info['category']=='core')
+ {
+ $trace = debug_backtrace();
+ $info['category'] = $trace[3]['class'];
+ }
+ $info['time'] = microtime(true);
+ $this->entries[] = array($msg, $type, $info);
+ }
+}
+
+?>
\ No newline at end of file |