From bf67bc20b46f3e464a21ca618e367efa503c6df6 Mon Sep 17 00:00:00 2001 From: Silvio Date: Fri, 20 Aug 2010 16:34:03 -0300 Subject: Class logger for IsisAudit --- apps/audit.php | 8 +++++--- classes/IsisAudit.php | 22 +++++++++++++++++++--- 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/apps/audit.php b/apps/audit.php index 9863e2d..0bd560b 100644 --- a/apps/audit.php +++ b/apps/audit.php @@ -15,10 +15,12 @@ $isis = new IsisAudit(); // Setup database and entry number. if ($isis) { // Run audit. - $result = $isis->run(); + $isis->run(); - // Format output. - $display->pre(print_r($result)); + // Display log messages. + foreach ($isis->log as $message) { + $display->pre(print_r($message)); + } } $display->footer(); diff --git a/classes/IsisAudit.php b/classes/IsisAudit.php index 63446e1..f2435a9 100644 --- a/classes/IsisAudit.php +++ b/classes/IsisAudit.php @@ -4,6 +4,22 @@ * Methods for auditing an Isis database. */ class IsisAudit extends IsisFinder { + /** + * @var $log + * Log messages. + */ + var $log; + + /** + * Class logger. + * + * @param $message + * Log message. + */ + function logger($message) { + $this->log[] = $message; + } + /** * Run a standard audit procedure. */ @@ -13,10 +29,10 @@ class IsisAudit extends IsisFinder { // Check for repetitions. if ($field['repeat'] && !$repetition) { - echo "Field ". $field['name'] ." is configured for repetitions but no repetitions found.\n"; + $this->logger("Field ". $field['name'] ." is configured for repetitions but no repetitions found."); } elseif (!$field['repeat'] && $repetition) { - echo "Field ". $field['name'] ." is not configured for repetitions but a repetition was found for entry ". $repetition[0] .".\n"; + $this->logger("Field ". $field['name'] ." is not configured for repetitions but a repetition was found for entry ". $repetition[0] ."."); } // Check for subfields. @@ -25,7 +41,7 @@ class IsisAudit extends IsisFinder { $next_subfield = $this->nextSubfield($field, $subfield); if (!$next_subfield) { - echo "No occurrences found for field ". $field['name'] ." and subfield $subfield\n"; + $this->logger("No occurrences found for field ". $field['name'] ." and subfield $subfield."); } } } -- cgit v1.2.3