aboutsummaryrefslogtreecommitdiff
path: root/lib/sfIsisImporterLog.class.php
diff options
context:
space:
mode:
Diffstat (limited to 'lib/sfIsisImporterLog.class.php')
-rw-r--r--lib/sfIsisImporterLog.class.php57
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);
}