nl_tokens: Log messages to the console and history based on the type of message
pl_tokens: function logByType ( type , args ) { var stringify = arguments . length > 2 && arguments [ 2 ] !== undefined ? arguments [ 2 ] : ! ! IE_VERSION && IE_VERSION < 11 ; var lvl = log . levels [ level ] ; var lvlRegExp = new RegExp ( '^(' + lvl + ')$' ) ; if ( type !== 'log' ) { // Add the type to the front of the message when it's not "log". args . unshift ( type . toUpperCase ( ) + ':' ) ; } // Add a clone of the args at this point to history. if ( history ) { history . push ( [ ] . concat ( args ) ) ; } // Add console prefix after adding to history. args . unshift ( 'VIDEOJS:' ) ; // If there's no console then don't try to output messages, but they will // still be stored in history. // // Was setting these once outside of this function, but containing them // in the function makes it easier to test cases where console doesn't exist // when the module is executed. var fn = window . console && window . console [ type ] ; // Bail out if there's no console or if this type is not allowed by the // current logging level. if ( ! fn || ! lvl || ! lvlRegExp . <mask> ( type ) ) { return ; } // IEs previous to 11 log objects uselessly as "[object Object]"; so, JSONify // objects and arrays for those less-capable browsers. if ( stringify ) { args = args . map ( function ( a ) { if ( isObject ( a ) || Array . isArray ( a ) ) { try { return JSON . stringify ( a ) ; } catch ( x ) { return String ( a ) ; } } // Cast to string before joining, so we get null and undefined explicitly // included in output (as we would in a modern console). return String ( a ) ; } ) . join ( ' ' ) ; } // Old IE versions do not allow .apply() for console methods (they are // reported as objects rather than functions). if ( ! fn . apply ) { fn ( args ) ; } else { fn [ Array . isArray ( args ) ? 'apply' : 'call' ] ( window . console , args ) ; } }