Quantcast
Viewing all articles
Browse latest Browse all 82112

Warning level control - with suggestion

If I may suggest the following code to _fnLog, to add a more flexible control of warnings and debugging:

function _fnLog( oSettings, iLevel, sMesg )
{
	var sAlert = (oSettings===null) ?
		"DataTables warning: "+sMesg :
		"DataTables warning (table id = '"+oSettings.sTableId+"'): "+sMesg;
	
	if ( iLevel === 0 )
	{
		if ( DataTable.ext.sErrMode == 'alert' )
		{
			alert( sAlert );
		}
		else if ( DataTable.ext.sErrMode == 'thow' )
		{
			throw sAlert;
		}
		else  if ( DataTable.ext.sErrMode == 'console' )
		{
			console.log( sAlert );
		}
		else  if ( DataTable.ext.sErrMode == 'mute' )
		{}
		return;
	}
	else if ( console !== undefined && console.log )
	{
		console.log( sAlert );
	}
}


Along with adding the usual sErrMode param on the user code:

$(function () {
 
 $.fn.dataTableExt.sErrMode = 'mute'; //check above for other options  
    
    //.... code ....

});	

What it adds is flexibility to improve faster development when facing non-disruptive warning situations. In my case it kept issued warnings but in the end the result was a perfect DT anyway. So making it mute was just fine (it was getting really boring with the alerts and just blocking with the throw).

It is working nicely this way. Just to consider.

Thanks,

Wellington

Viewing all articles
Browse latest Browse all 82112

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>