Created
February 28, 2017 10:47
-
-
Save morrelinko/64da188eb704ecfadb72b82ead7f6ead to your computer and use it in GitHub Desktop.
VueJS $log Plugin - Log objects without reactive getters & setters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict' | |
import _ from 'lodash' | |
let Log = _.noop | |
Log.install = function (Vue, options) { | |
Vue.prototype.$log = function (...args) { | |
try { | |
console.log(...args.map(arg => _.isPlainObject(arg) ? JSON.parse(JSON.stringify(arg)) : arg)) | |
} catch (e) { | |
// Try to handle cases with circular dependencies | |
console.log(...args.map(arg => _.toPlainObject(arg))) | |
} | |
} | |
} | |
export default Log |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment