@@ -312,24 +312,23 @@ cc._initDebugSetting = function (mode) {
312312 } else if ( console && console . log . apply ) { //console is null when user doesn't open dev tool on IE9
313313 //log to console
314314
315- cc . error = function ( ) {
316- return console . error . apply ( console , arguments ) ;
317- } ;
318- cc . assert = function ( cond , msg ) {
319- if ( ! cond && msg ) {
320- for ( var i = 2 ; i < arguments . length ; i ++ )
321- msg = msg . replace ( / ( % s ) | ( % d ) / , cc . _formatString ( arguments [ i ] ) ) ;
322- throw new Error ( msg ) ;
323- }
324- } ;
325- if ( mode !== ccGame . DEBUG_MODE_ERROR )
326- cc . warn = function ( ) {
327- return console . warn . apply ( console , arguments ) ;
328- } ;
329- if ( mode === ccGame . DEBUG_MODE_INFO )
330- cc . log = function ( ) {
331- return console . log . apply ( console , arguments ) ;
315+ cc . error = Function . prototype . bind . call ( console . error , console ) ;
316+ //If console.assert is not support user throw Error msg on wrong condition
317+ if ( console . assert ) {
318+ cc . assert = Function . prototype . bind . call ( console . assert , console ) ;
319+ } else {
320+ cc . assert = function ( cond , msg ) {
321+ if ( ! cond && msg ) {
322+ for ( var i = 2 ; i < arguments . length ; i ++ )
323+ msg = msg . replace ( / ( % s ) | ( % d ) / , cc . _formatString ( arguments [ i ] ) ) ;
324+ throw new Error ( msg ) ;
325+ }
332326 } ;
327+ }
328+ if ( mode !== ccGame . DEBUG_MODE_ERROR )
329+ cc . warn = Function . prototype . bind . call ( console . warn , console ) ;
330+ if ( mode === ccGame . DEBUG_MODE_INFO )
331+ cc . log = Function . prototype . bind . call ( console . log , console ) ;
333332 }
334333} ;
335- //+++++++++++++++++++++++++something about log end+++++++++++++++++++++++++++++
334+ //+++++++++++++++++++++++++something about log end+++++++++++++++++++++++++++++
0 commit comments