services/logger.js
function getLocation() {
    var trace = stackTrace.get();

    //trace.forEach(function(e){
    //    console.log('mytrace: ' + e.getFileName());
    //});

    //use (start at) index 2 because 0 is the call to getLocation, and 1 is the call to logger
    //  However, component loggers put an extra level in, so search down until the location is not 'logger'
    //  There's code to search a long way down the stack, but in practice the next (3) will be hit and used
    //    since its name is not logger.
    var idx = 2;
    var modNm = 'logger';
    var rmodNm = null;
    var skip = ['logger', 'logger.js'];
    while ((_.includes(skip, modNm)) && trace.length > idx) {
        var fpath = trace[idx].getFileName();
        ++idx;
        if (fpath.slice(0, 'native'.length) === 'native') {
            continue; // skip native modules
        }
        modNm = null;
        var mod = null;
        try {
            mod = require(fpath);
        } catch (err) {
            // do nothing here, it's checked later
        }
        if (mod) { //__id is injected into services by the loader
            if (!mod.__id) {
                modNm = _.split(fpath, '/').pop();
                rmodNm = modNm;
            } else {
                modNm = mod.__id;
                if (modNm !== null) {
                    rmodNm = modNm;
                }
            }
        } else {
            modNm = _.split(fpath, '/').pop();
            rmodNm = modNm;
        }

    }
    return rmodNm;
}
function getLocation() {
    var trace = stackTrace.get();

    //trace.forEach(function(e){
    //    console.log('mytrace: ' + e.getFileName());
    //});

    //use (start at) index 2 because 0 is the call to getLocation, and 1 is the call to logger
    //  However, component loggers put an extra level in, so search down until the location is not 'logger'
    //  There's code to search a long way down the stack, but in practice the next (3) will be hit and used
    //    since its name is not logger.
    var idx = 2;
    var modNm = 'logger';
    var rmodNm = null;
    var skip = ['logger', 'logger.js'];
    while ((_.includes(skip, modNm)) && trace.length > idx) {
        var fpath = trace[idx].getFileName();
        ++idx;
        if (fpath.slice(0, 'native'.length) === 'native') {
            continue; // skip native modules
        }
        modNm = null;
        var mod = null;
        try {
            mod = require(fpath);
        } catch (err) {
            // do nothing here, it's checked later
        }
        if (mod) { //__id is injected into services by the loader
            if (!mod.__id) {
                modNm = _.split(fpath, '/').pop();
                rmodNm = modNm;
            } else {
                modNm = mod.__id;
                if (modNm !== null) {
                    rmodNm = modNm;
                }
            }
        } else {
            modNm = _.split(fpath, '/').pop();
            rmodNm = modNm;
        }

    }
    return rmodNm;
}
function getLocation ( ) { var trace = stackTrace . get ( ) ; //trace.forEach(function(e){ //    console.log('mytrace: ' + e.getFileName()); //}); //use (start at) index 2 because 0 is the call to getLocation, and 1 is the call to logger //  However, component loggers put an extra level in, so search down until the location is not 'logger' //  There's code to search a long way down the stack, but in practice the next (3) will be hit and used //    since its name is not logger. var idx = 2 ; var modNm = 'logger' ; var rmodNm = null ; var skip = [ 'logger' , 'logger.js' ] ; while ( ( _ . includes ( skip , modNm ) ) && trace . length > idx ) { var fpath = trace [ idx ] . getFileName ( ) ; ++ idx ; if ( fpath . slice ( 0 , 'native' . length ) === 'native' ) { continue ; // skip native modules } modNm = null ; var mod = null ; try { mod = require ( fpath ) ; } catch ( err ) { // do nothing here, it's checked later } if ( mod ) { //__id is injected into services by the loader if ( ! mod . __id ) { modNm = _ . split ( fpath , '/' ) . pop ( ) ; rmodNm = modNm ; } else { modNm = mod . __id ; if ( modNm !== null ) { rmodNm = modNm ; } } } else { modNm = _ . split ( fpath , '/' ) . pop ( ) ; rmodNm = modNm ; } } return rmodNm ; }
Determine the name of the service or javascript module that called logger
Determine the name of the service or javascript module that called logger