From bcd3e33ed3e1642a04ae80152cc06604137a9e23 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Andreas=20=C3=85kre=20Solberg?= <andreas.solberg@uninett.no>
Date: Mon, 9 Mar 2009 11:20:59 +0000
Subject: [PATCH] Print output when run from cmdline..

git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@1389 44740490-163a-0410-bde0-09ae8108e29a
---
 modules/statistics/bin/loganalyzer.php |  2 +-
 modules/statistics/lib/Aggregator.php  | 11 +++++++----
 2 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/modules/statistics/bin/loganalyzer.php b/modules/statistics/bin/loganalyzer.php
index 913fc4168..644b5d40d 100755
--- a/modules/statistics/bin/loganalyzer.php
+++ b/modules/statistics/bin/loganalyzer.php
@@ -51,7 +51,7 @@ foreach($argv as $a) {
 		}
 }
 
-$aggregator = new sspmod_statistics_Aggregator();
+$aggregator = new sspmod_statistics_Aggregator(TRUE);
 $aggregator->dumpConfig();
 $results = $aggregator->aggregate($debug);
 
diff --git a/modules/statistics/lib/Aggregator.php b/modules/statistics/lib/Aggregator.php
index d5314759b..46e41f365 100644
--- a/modules/statistics/lib/Aggregator.php
+++ b/modules/statistics/lib/Aggregator.php
@@ -12,11 +12,14 @@ class sspmod_statistics_Aggregator {
 	private $statrules;
 	private $offset;
 
+	private $fromcmdline;
+
 	/**
 	 * Constructor
 	 */
-	public function __construct() {
+	public function __construct($fromcmdline = FALSE) {
 	
+		$this->fromcmdline = $fromcmdline;
 		$this->statconfig = SimpleSAML_Configuration::getConfig('module_statistics.php');
 		
 		$this->statdir = $this->statconfig->getValue('statdir');
@@ -70,9 +73,9 @@ class sspmod_statistics_Aggregator {
 			$content = $logparser->parseContent($logline);
 			$action = trim($content[5]);
 
-				if (($i % 10000) == 0) {
-					echo("Read line " . $i . "\n");
-				}
+			if ($this->fromcmdline && ($i % 10000) == 0) {
+				echo("Read line " . $i . "\n");
+			}
 
 			
 			if ($debug) {
-- 
GitLab