lib/console.js
function(level, title, format, filters, needstack, args) {
        var msg = utils.format.apply(this, args)
        var data = {
            timestamp : dateFormat(new Date(), _config.dateformat),
            message : msg,
            title : title,
            level : level,
            args : args
        }

        data.method = data.path = data.line = data.pos = data.file = ''

        if (needstack) {
            // get call stack, and analyze it
            // get all file,method and line number
            data.stack = (new Error()).stack.split('\n').slice(3)

            // Stack trace format :
            // http://code.google.com/p/v8/wiki/JavaScriptStackTraceApi
            var s = data.stack[0], sp = /at\s+(.*)\s+\((.*):(\d*):(\d*)\)/gi
                    .exec(s) || /at\s+()(.*):(\d*):(\d*)/gi.exec(s)

            if (sp && sp.length === 5) {
                data.method = sp[1]
                data.path = sp[2]
                data.line = sp[3]
                data.pos = sp[4]
                var paths = data.path.split('/')
                data.file = paths[paths.length - 1]
            }
        }

        _config.preprocess(data)

        // call micro-template to ouput
        data.output = tinytim.tim(format, data)

        // process every filter method
        var len = filters.length

        for ( var i = 0; i < len; i += 1) {
            data.output = filters[i](data.output, data)
            if (!data.output)
                return data
            // cancel next process if return a false(include null, undefined)
        }
        // trans the final result
        return _config.transport(data)
    }
function(level, title, format, filters, needstack, args) {
        var msg = utils.format.apply(this, args)
        var data = {
            timestamp : dateFormat(new Date(), _config.dateformat),
            message : msg,
            title : title,
            level : level,
            args : args
        }

        data.method = data.path = data.line = data.pos = data.file = ''

        if (needstack) {
            // get call stack, and analyze it
            // get all file,method and line number
            data.stack = (new Error()).stack.split('\n').slice(3)

            // Stack trace format :
            // http://code.google.com/p/v8/wiki/JavaScriptStackTraceApi
            var s = data.stack[0], sp = /at\s+(.*)\s+\((.*):(\d*):(\d*)\)/gi
                    .exec(s) || /at\s+()(.*):(\d*):(\d*)/gi.exec(s)

            if (sp && sp.length === 5) {
                data.method = sp[1]
                data.path = sp[2]
                data.line = sp[3]
                data.pos = sp[4]
                var paths = data.path.split('/')
                data.file = paths[paths.length - 1]
            }
        }

        _config.preprocess(data)

        // call micro-template to ouput
        data.output = tinytim.tim(format, data)

        // process every filter method
        var len = filters.length

        for ( var i = 0; i < len; i += 1) {
            data.output = filters[i](data.output, data)
            if (!data.output)
                return data
            // cancel next process if return a false(include null, undefined)
        }
        // trans the final result
        return _config.transport(data)
    }
function ( level , title , format , filters , needstack , args ) { var msg = utils . format . apply ( this , args ) var data = { timestamp : dateFormat ( new Date ( ) , _config . dateformat ) , message : msg , title : title , level : level , args : args } data . method = data . path = data . line = data . pos = data . file = '' if ( needstack ) { // get call stack, and analyze it // get all file,method and line number data . stack = ( new Error ( ) ) . stack . split ( '\n' ) . slice ( 3 ) // Stack trace format : // http://code.google.com/p/v8/wiki/JavaScriptStackTraceApi var s = data . stack [ 0 ] , sp = / at\s+(.*)\s+\((.*):(\d*):(\d*)\) / gi . exec ( s ) || / at\s+()(.*):(\d*):(\d*) / gi . exec ( s ) if ( sp && sp . length === 5 ) { data . method = sp [ 1 ] data . path = sp [ 2 ] data . line = sp [ 3 ] data . pos = sp [ 4 ] var paths = data . path . split ( '/' ) data . file = paths [ paths . length - 1 ] } } _config . preprocess ( data ) // call micro-template to ouput data . output = tinytim . tim ( format , data ) // process every filter method var len = filters . length for ( var i = 0 ; i < len ; i += 1 ) { data . output = filters [ i ] ( data . output , data ) if ( ! data . output ) return data // cancel next process if return a false(include null, undefined) } // trans the final result return _config . transport ( data ) }
main log method
main log method