diff options
author | Silvio <s1lv10@uol.com.br> | 2010-07-30 14:06:16 -0300 |
---|---|---|
committer | Silvio <s1lv10@uol.com.br> | 2010-07-30 14:06:16 -0300 |
commit | bf508ab1add876a8670ad1831a84f57791b462a5 (patch) | |
tree | 3a07f9968d6da75463c8c1cbbf641e97d7ef6572 /lib/sfIsisImporterLog.class.php | |
parent | ced40675a32339e7a2cef492792d89ad1d2adc1f (diff) | |
download | sf_isis_importer_plugin-bf508ab1add876a8670ad1831a84f57791b462a5.tar.gz sf_isis_importer_plugin-bf508ab1add876a8670ad1831a84f57791b462a5.tar.bz2 |
Logging changes
Diffstat (limited to 'lib/sfIsisImporterLog.class.php')
-rw-r--r-- | lib/sfIsisImporterLog.class.php | 57 |
1 files changed, 47 insertions, 10 deletions
diff --git a/lib/sfIsisImporterLog.class.php b/lib/sfIsisImporterLog.class.php index 2dcd4a3..7cf50a3 100644 --- a/lib/sfIsisImporterLog.class.php +++ b/lib/sfIsisImporterLog.class.php @@ -1,24 +1,32 @@ <?php /** - * Logger. - * - * @todo $this->caller, $this->section + * sfIsisImporterLog provides basic logging facilities for import procedures. */ class sfIsisImporterLog { /** - * @var object $instance The singleton instance. + * @var object $instance The singleton instance */ private static $instance = null; /** - * @var object $instance Default loglevel. + * @var object $loglevel Log level */ public static $loglevel; /** - * @var int $processed Number of processed entries. + * @var object $section Log section + */ + public static $section = false; + + /** + * @var object $caller Log caller + */ + public static $caller = false; + + /** + * @var int $processed Number of processed entries */ var $processed = 0; @@ -41,7 +49,7 @@ class sfIsisImporterLog */ private function __construct($loglevel = 'info') { - $this->level($loglevel); + $this->setLevel($loglevel); } /** @@ -49,12 +57,32 @@ class sfIsisImporterLog * * @param string $loglevel Log level to use */ - public function level($loglevel) + public function setLevel($loglevel) { $this->loglevel = $loglevel; } /** + * Set the log section. + * + * @param string $section Log section to use + */ + public function setSection($section) + { + $this->section = $section; + } + + /** + * Set the log caller. + * + * @param string $caller Log caller to use + */ + public function setCaller($caller) + { + $this->caller = $caller; + } + + /** * Get the available log levels ordered by verbosity. * * @return array Log levels @@ -93,7 +121,16 @@ class sfIsisImporterLog } else { - $this->caller->logSection('isisImporter', "[$level] $message"); + $message = "[$level] $message"; + + if ($this->caller) + { + $this->caller->logSection('isisImporter', $message); + } + else + { + echo ("$message\n"); + } } } @@ -115,7 +152,7 @@ class sfIsisImporterLog else { // Progress bar is just shown if loglevel is 'fatal' or lower. - if ($levels['fatal'] >= $levels[$this->loglevel]) + if ($levels['fatal'] >= $levels[$this->loglevel] && $this->caller) { $this->caller->progressBar($entry, $entries); } |