aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorSilvio <s1lv10@uol.com.br>2010-07-30 14:06:16 -0300
committerSilvio <s1lv10@uol.com.br>2010-07-30 14:06:16 -0300
commitbf508ab1add876a8670ad1831a84f57791b462a5 (patch)
tree3a07f9968d6da75463c8c1cbbf641e97d7ef6572 /lib
parentced40675a32339e7a2cef492792d89ad1d2adc1f (diff)
downloadsf_isis_importer_plugin-bf508ab1add876a8670ad1831a84f57791b462a5.tar.gz
sf_isis_importer_plugin-bf508ab1add876a8670ad1831a84f57791b462a5.tar.bz2
Logging changes
Diffstat (limited to 'lib')
-rw-r--r--lib/sfIsisImporterLog.class.php57
-rw-r--r--lib/sfIsisImporterManager.class.php8
2 files changed, 50 insertions, 15 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);
}
diff --git a/lib/sfIsisImporterManager.class.php b/lib/sfIsisImporterManager.class.php
index d261f67..aca0aae 100644
--- a/lib/sfIsisImporterManager.class.php
+++ b/lib/sfIsisImporterManager.class.php
@@ -119,11 +119,9 @@ class sfIsisImporterManager extends IsisConnector
*/
public function massImport($caller, $section, $entries = NULL)
{
- // We hold arguments for logging purposes.
- $this->caller = $caller;
- $this->section = $section;
- $this->logger->caller = $caller;
- $this->logger->section = $section;
+ // Additional logging settings.
+ $this->logger->setCaller($caller);
+ $this->logger->setSection($section);
foreach ($this->databases() as $database)
{