Skip to content

Instantly share code, notes, and snippets.

@morrelinko
Created February 28, 2017 10:47
Show Gist options
  • Save morrelinko/64da188eb704ecfadb72b82ead7f6ead to your computer and use it in GitHub Desktop.
Save morrelinko/64da188eb704ecfadb72b82ead7f6ead to your computer and use it in GitHub Desktop.
VueJS $log Plugin - Log objects without reactive getters & setters
'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