From ad9106b3ce58c04daa44a7a2fa67457fb05ca919 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Andreas=20=C3=85kre=20Solberg?= <andreas.solberg@uninett.no>
Date: Sun, 1 Mar 2009 10:55:23 +0000
Subject: [PATCH] Add support for log capturing. used in ldapstatus module.

git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@1344 44740490-163a-0410-bde0-09ae8108e29a
---
 lib/SimpleSAML/Logger.php | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/lib/SimpleSAML/Logger.php b/lib/SimpleSAML/Logger.php
index a951a5c52..8b2c66d62 100644
--- a/lib/SimpleSAML/Logger.php
+++ b/lib/SimpleSAML/Logger.php
@@ -16,6 +16,9 @@ interface SimpleSAML_Logger_LoggingHandler {
 class SimpleSAML_Logger {
 	private static $loggingHandler = null;
 	private static $logLevel = null;
+	
+	private static $captureLog = FALSE;
+	private static $capturedLog = array();
 
 	/**
 	 * This constant defines the string we set the trackid to while we are fetching the
@@ -137,10 +140,20 @@ class SimpleSAML_Logger {
 		self::$loggingHandler = $sh;
 	}
 	
+	public static function setCaptureLog($val = TRUE) {
+		self::$captureLog = $val;
+	}
+	
+	public static function getCapturedLog() {
+		return self::$capturedLog;
+	}	
+	
 	static function log_internal($level,$string,$statsLog = false) {
 		if (self::$loggingHandler == null)
 			self::createLoggingHandler();
 		
+		if (self::$captureLog) self::$capturedLog[] = $string;
+		
 		if (self::$logLevel >= $level || $statsLog) {
 			if (is_array($string)) $string = implode(",",$string);
 			$string = '['.self::getTrackId().'] '.$string;
-- 
GitLab