Skip to content

Latest commit

 

History

History
39 lines (31 loc) · 1.29 KB

CONSOLE_LOG_OVERRIDE.md

File metadata and controls

39 lines (31 loc) · 1.29 KB

Colorful console.log with util-inspect

In previous versions of NativeScript-Vue console.log was overriden to bring better logging and colors to your console. It was removed in this commit to improve perfomance and reduce the size of our bundle.

If you however need this in your app, you can bring it back at an application level.

Keep in mind that this override should not be present in production.

$ npm install --save-dev util-inspect

In your main app file:

import Vue from 'nativescript-vue'

if (TNS_ENV !== 'production') {
    const inspect = require('util-inspect');
    const newLineRegExp = /\\n/g
    console.log = (function(log, inspect, Vue) {
        return function(...args) {
            return log.call(
                this,
                ...Array.prototype.map.call(args, function(arg) {
                    return inspect(arg, {
                    depth: 2,
                    colors: Vue.config.debug,
                    showHidden: true
                    }).replace(newLineRegExp, '\n')
                })
            )
        }
    })(console.log, inspect, Vue);
}

With this change, everything should work the way it worked before we removed our override.