Clean up docblock on base namespace objects
[gitphp.git] / include / DebugLog.class.php
blob:a/include/DebugLog.class.php -> blob:b/include/DebugLog.class.php
--- a/include/DebugLog.class.php
+++ b/include/DebugLog.class.php
@@ -6,16 +6,9 @@
  * @copyright Copyright (c) 2010 Christopher Han
  * @package GitPHP
  */
-class GitPHP_DebugLog
+class GitPHP_DebugLog implements GitPHP_Observer_Interface
 {
 	/**
-	 * Stores the singleton instance
-	 *
-	 * @var GitPHP_DebugLog
-	 */
-	protected static $instance;
-
-	/**
 	 * Stores whether logging is enabled
 	 *
 	 * @var boolean
@@ -49,29 +42,6 @@
 	 * @var string[]
 	 */
 	protected $entries = array();
-
-	/**
-	 * Returns the singleton instance
-	 *
-	 * @return GitPHP_DebugLog instance of logging class
-	 */
-	public static function GetInstance()
-	{
-		if (!self::$instance) {
-			$config = GitPHP_Config::GetInstance();
-			self::$instance = new GitPHP_DebugLog($config->GetValue('debug', false), $config->GetValue('benchmark', false));
-		}
-
-		return self::$instance;
-	}
-
-	/**
-	 * Releases the singleton instance
-	 */
-	public static function DestroyInstance()
-	{
-		self::$instance = null;
-	}
 
 	/**
 	 * Constructor
@@ -79,7 +49,7 @@
 	 * @param boolean $enabled whether log should be enabled
 	 * @param boolean $benchmark whether benchmarking should be enabled
 	 */
-	private function __construct($enabled = false, $benchmark = false)
+	public function __construct($enabled = false, $benchmark = false)
 	{
 		$this->startTime = microtime(true);
 		$this->startMem = memory_get_usage();
@@ -209,5 +179,36 @@
 		return $data;
 	}
 
+	/**
+	 * Clears the log
+	 */
+	public function Clear()
+	{
+		$this->entries = array();
+	}
+
+	/**
+	 * Notify that observable object changed
+	 *
+	 * @param GitPHP_Observable_Interface $object object
+	 * @param int $changeType type of change
+	 * @param array $args argument array
+	 */
+	public function ObjectChanged($object, $changeType, $args = array())
+	{
+		if ($changeType !== GitPHP_Observer_Interface::LoggableChange)
+			return;
+
+		if (!$this->enabled)
+			return;
+
+		if (!isset($args[0]) || empty($args[0]))
+			return;
+
+		$msg = $args[0];
+
+		$this->Log($msg);
+	}
+
 }
 

comments