/// <reference path="C:\References\jquery-1.4.1-vsdoc.js" />

// ********************************************************************
// 
// Manheim Retail Marketing
// ********************************************************************
// Copyright © 2010 Manheim Retail Marketing.
//
//  Summary
// ******************************
// $Workfile: TracingConsole.js $
// Notes:		Provides common tracing functionality.
//
// File History Information
// ************************
// Created on:					    
// Last Modified:					$Modtime: 24/08/10 10:29 $
// Original Author:					Marc Lancashire
// Last Modified by:				$Author: Lancashirem $
// Last JS Lint:					07/12/2009 11:40
//
// Source Control Information
// **************************
// File Version:					$Revision: 2 $
// VSS Location:					$Archive: /Manheim.Portfolio/Manheim.Portfolio.Web.UI.Client.Assets/assets/js/mrm/lib/utilities/1.0/TracingConsole.js $
//
// ********************************************************************

// Check / create namespace
if (!mrm.global.isNamespaceDefined("mrm.lib.utilities"))
{
	mrm.global.createNamespace("mrm.lib.utilities", "1.0");
}


// Class definition
mrm.lib.utilities.Tracing = Object.subClass
(
{
	
	/*
	=============================
	CONSTANTS
	=============================
	*/
	
	"_consoleEnabled"	: true,
	"_tracingEnabled"	: false,
	"_tracePrefix"		: "Tracing Prefix",
	"_traces"			: [],
	
	/*
	=============================
	CONSTRUCTOR
	=============================
	*/
	
	"init" : function (enable, prefix)
	{
		this._tracingEnabled	= enable;
		this._tracePrefix		= prefix;
		
		// check if console mode is enabled
		if(!window.console)
		{
			this._consoleEnabled = false;
			this._tracingEnabled = false;
		}
	},
	
	/*
	=============================
	PUBLIC MEMBERS
	=============================
	*/
	
	"addTrace" : function (message)
	{
		if (this._tracingEnabled && this._consoleEnabled)
		{
			// create trace item
			var trace = {"id" : this._traces.length, "timestamp" : new Date(), "trace" : this._tracePrefix + " " + message};
			
			// add to array
			this._traces[this._traces.length] = trace;
			
			// out to console
			console.log("id = " + trace.id + ", time = " + trace.timestamp + ", " + trace.trace);
			//console.log(trace);
		}
	},
	
	"clearTrace" : function ()
	{
		this._traces = [];
	},
	
	"traces" : function ()
	{
		return this._traces;
	},
	
	// full output of current tracings
	"outputTrace" : function ()
	{
		return "See javascript console in ff use -console.";
	}
	
	/*
	=============================
	PRIVATE MEMBERS
	=============================
	*/
}
);
