


var	spDebug	= {
	
	info: function() {
		log.info(this.formatMessage($A(arguments)));
	},
	
	profile: function() {
		log.profile(this.formatMessage($A(arguments)));
	},
	
	error: function() {
		log.error(this.formatMessage($A(arguments)));
	},

	warn: function() {
		log.warn(this.formatMessage($A(arguments)));
	},

	formatMessage: function(parameters) {
		var	message	= '';
		
		parameters.each(
					function(el) {
						if(Object.isString(el)) {
							message	= message + '<ul><li>' + el + '</li></ul>';
						} else {
							message	= message + spDebug.inspect(el, 10);
						}
					}
				
				);
		
		return	message;
	},
	
	//	retourne une chaine HTML d'un objet
	inspect	: function (obj, maxLevels, level) {
	  var str = '', type, msg;

	    // Start Input Validations
	    // Don't touch, we start iterating at level zero
	    if(level == null)  level = 0;

	    // At least you want to show the first level
	    if(maxLevels == null) maxLevels = 1;
	    if(maxLevels < 1)     
	        return '<font color="red">Error: Levels number must be > 0</font>';

	    // We start with a non null object
	    if(obj == null)
	    return '<font color="red">Error: Object <b>NULL</b></font>';
	    // End Input Validations

	    // Each Iteration must be indented
	    str += '<ul style="padding-left: 10px;">';

	    // Start iterations for all objects in obj
	    for(property in obj)
	    {
	      try
	      {
	          // Show "property" and "type property"
	          type =  typeof(obj[property]);
	          str += '<li>(' + type + ') ' + property + ' : ' + ( (obj[property]==null)?(' <b>null</b>'):(obj[property])) + '</li>';

	          // We keep iterating if this property is an Object, non null
	          // and we are inside the required number of levels
	          if((type == 'object') && (obj[property] != null) && (level+1 < maxLevels)) {
	        	  str += this.inspect(obj[property], maxLevels, level+1);
	          }
	      }
	      catch(err)
	      {
	        // Is there some properties in obj we can't access? Print it red.
	        if(typeof(err) == 'string') msg = err;
	        else if(err.message)        msg = err.message;
	        else if(err.description)    msg = err.description;
	        else                        msg = 'Unknown';

	        str += '<li><font color="red">(Error) ' + property + ': ' + msg +'</font></li>';
	      }
	    }

	      // Close indent
	      str += '</ul>';

	    return str;
	}	
				
};





