<?php
class SableDebug
{
	static function debug($var, $ignoreDebugging = 0)
	{
		if (SABLE_SITE_DEBUGGING || $ignoreDebugging)
		{
			echo "<pre>";
			$backtrace = debug_backtrace();
			echo "<span style='color:#FE7C00'>";
			echo "Debug Message : ".$backtrace[0]['file'].":".$backtrace[0]['line']."\n----------------------------------------------------------------------------\n";
			print_r($var);
			echo "\n</span></pre>\n";
		}
	}
	
	static function debugx($var, $ignoreDebugging = 0)
	{
		if (SABLE_SITE_DEBUGGING || $ignoreDebugging)
		{
			echo "<pre>";
			$backtrace = debug_backtrace();
			echo "<span style='color:#FE7C00'>";
			echo "Debug Message : ".$backtrace[0]['file'].":".$backtrace[0]['line']."\n----------------------------------------------------------------------------\n";
			print_r($var);
			echo "\n</span></pre>\n";
			die('debugging: '.$backtrace[0]['file'].":".$backtrace[0]['line']);
		}
	}
	
	static function debugout($message, $ignoreDebugging = 0)
	{
		if (SABLE_SITE_DEBUGGING || $ignoreDebugging) 
		{
			$backtrace = debug_backtrace();
			echo('[File:'.$backtrace[0]['file'].', Line:'.$backtrace[0]['line'].']: '.$message.'<br />');
		}
	}
	
	static function debugoutx($message, $ignoreDebugging = 0)
	{
		if (SABLE_SITE_DEBUGGING || $ignoreDebugging) 
		{
			$backtrace = debug_backtrace();
			die('[File:'.$backtrace[0]['file'].', Line:'.$backtrace[0]['line'].']: '.$message.'<br />');
		}
	}
	
	static function debugfetch($message, $filename = 'debug_fetch')
	{
		$backtrace = debug_backtrace();
		file_put_contents(SABLE_WORKING_PATH.'lib/output/'.$filename.'.txt', PHP_EOL.'=== '.date('Y-m-d H:i:s').' === [File:'.$backtrace[0]['file'].', Line:'.$backtrace[0]['line'].']: ', FILE_APPEND);
		file_put_contents(SABLE_WORKING_PATH.'lib/output/'.$filename.'.txt', PHP_EOL.print_r($message, true), FILE_APPEND);
	}
	
	
}
?>