summaryrefslogtreecommitdiff
path: root/framework/Log
diff options
context:
space:
mode:
Diffstat (limited to 'framework/Log')
-rw-r--r--framework/Log/TEventLog.php40
-rw-r--r--framework/Log/TLog.php13
-rw-r--r--framework/Log/TLogManager.php (renamed from framework/Log/TEzcLogger.php)22
3 files changed, 46 insertions, 29 deletions
diff --git a/framework/Log/TEventLog.php b/framework/Log/TEventLog.php
index d291d3f5..8fb56618 100644
--- a/framework/Log/TEventLog.php
+++ b/framework/Log/TEventLog.php
@@ -1,7 +1,7 @@
<?php
-require_once(dirname(__FILE__).'/TLog.php');
-require_once(dirname(__FILE__).'/TEzcLogger.php');
+Prado::using('System.Log.ILog');
+Prado::using('System.Log.TLogManager');
/**
* ${classname}
@@ -12,45 +12,67 @@ require_once(dirname(__FILE__).'/TEzcLogger.php');
* @version $Revision: 1.66 $ $Date: ${DATE} ${TIME} $
* @package ${package}
*/
-class TEventLog extends TEzcLogger implements TLog
+class TEventLog extends TLogManager implements ILog
{
+ public function init($config)
+ {
+ parent::init($config);
+ $this->collectInternalLog();
+ }
+
+ public function __destruct()
+ {
+ $this->collectInternalLog();
+ }
+
+ protected function collectInternalLog()
+ {
+ foreach(Prado::coreLog()->entries as $entry)
+ $this->log($entry[0], $entry[1], $entry[2]);
+ Prado::coreLog()->entries = array();
+ }
public function info($msg, $source='Prado', $category='main')
{
- ezcLog::getInstance()->log($msg, ezcLog::INFO,
+ $this->log($msg, ezcLog::INFO,
array('source'=>$source, 'category'=>$category));
}
public function debug($msg, $source='Prado', $category='main')
{
- ezcLog::getInstance()->log($msg, ezcLog::DEBUG,
+ $this->log($msg, ezcLog::DEBUG,
array('source'=>$source, 'category'=>$category));
}
public function notice($msg, $source='Prado', $category='main')
{
- ezcLog::getInstance()->log($msg, ezcLog::NOTICE,
+ $this->log($msg, ezcLog::NOTICE,
array('source'=>$source, 'category'=>$category));
}
public function warn($msg, $source='Prado', $category='main')
{
- ezcLog::getInstance()->log($msg, ezcLog::WARNING,
+ $this->log($msg, ezcLog::WARNING,
array('source'=>$source, 'category'=>$category));
}
public function error($msg, $source='Prado', $category='main')
{
- ezcLog::getInstance()->log($msg, ezcLog::NOTICE,
+ $this->log($msg, ezcLog::NOTICE,
array('source'=>$source, 'category'=>$category));
}
public function fatal($msg, $source='Prado', $category='main')
{
- ezcLog::getInstance()->log($msg, ezcLog::NOTICE,
+ $this->log($msg, ezcLog::NOTICE,
array('source'=>$source, 'category'=>$category));
}
+
+ protected function log($msg, $code, $info)
+ {
+ ezcLog::getInstance()->log($msg, $code, $info);
+ }
}
?> \ No newline at end of file
diff --git a/framework/Log/TLog.php b/framework/Log/TLog.php
deleted file mode 100644
index 0a455c84..00000000
--- a/framework/Log/TLog.php
+++ /dev/null
@@ -1,13 +0,0 @@
-<?php
-
-interface TLog
-{
- public function info($msg, $source='Prado', $category='main');
- public function debug($msg, $source='Prado', $category='main');
- public function notice($msg, $source='Prado', $category='main');
- public function warn($msg, $source='Prado', $category='main');
- public function error($msg, $source='Prado', $category='main');
- public function fatal($msg, $source='Prado', $category='main');
-}
-
-?> \ No newline at end of file
diff --git a/framework/Log/TEzcLogger.php b/framework/Log/TLogManager.php
index 11fe6c7f..dba96e3a 100644
--- a/framework/Log/TEzcLogger.php
+++ b/framework/Log/TLogManager.php
@@ -1,6 +1,6 @@
<?php
-abstract class TEzcLogger extends TModule
+abstract class TLogManager extends TModule
{
protected $defaultSeverity = 'INFO | DEBUG | NOTICE | WARNING | ERROR | FATAL';
@@ -27,12 +27,12 @@ abstract class TEzcLogger extends TModule
TEzcLoggerLoader::using('ezcLogMap');
TEzcLoggerLoader::using('ezcLogContext');
TEzcLoggerLoader::using('ezcLogFilter');
- $loggers = $xml->getElementsByTagName('logger');
+
$log = ezcLog::getInstance();
- foreach($loggers as $logger)
+ foreach($xml->getElementsByTagName('logger') as $logger)
{
- $filters = $logger->getElementsByTagName('filter');
$logWriter = $this->getLogWriter($logger);
+ $filters = $logger->getElementsByTagName('filter');
foreach($filters as $filter)
{
$logFilter = new ezcLogFilter();
@@ -41,6 +41,13 @@ abstract class TEzcLogger extends TModule
$map = $filter->getAttribute('disabled') ? 'unmap' : 'map';
$log->$map($logFilter, $logWriter);
}
+
+ if($filters->Length < 1)
+ {
+ $logFilter = new ezcLogFilter();
+ $logFilter->severity = $this->getFilterSeverity();
+ $log->map($logFilter, $logWriter);
+ }
}
}
@@ -55,10 +62,10 @@ abstract class TEzcLogger extends TModule
}
}
- protected function getFilterSeverity($string)
+ protected function getFilterSeverity($string='')
{
if(empty($string))
- $string = $this->defaultServerity;
+ $string = $this->defaultSeverity;
$serverities = explode("|", $string);
$mask = 0;
foreach($serverities as $Severity)
@@ -101,7 +108,8 @@ class TEzcLoggerUnixFileWriterFactory
TEzcLoggerLoader::using('ezcLogWriterFile');
TEzcLoggerLoader::using('ezcLogWriterUnixFile');
- $dir = $xml->getAttribute('directory');
+ $path = $xml->getAttribute('directory');
+ $dir = Prado::getPathOfNamespace($path);
$file = $xml->getAttribute('filename');
if(empty($file)) $file = 'prado.log';
return new ezcLogWriterUnixFile($dir, $file);