Skip to content

Provides customizable logging functionality for Vue.js. Compatible with Vue2.

License

Notifications You must be signed in to change notification settings

jmharveys/vuejs-logger

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

39 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

vuejs-logger

codecov npm npm GitHub license

Provides customizable logging functionality for Vue.js. Compatible with Vue2.

Table of Contents

Demo

@ https://codepen.io/justinkames/pen/BwGOVQ

Introduction

vuejs-logger is a logging library that enables logging for Vue applications. It restricts log messages that are higher than the specified log level. Features include :

  • Colored console messages for $log.warning, $log.error and $log.fatal.
  • Possibility to automatically JSON.stringify() the (reactive) properties passed to the logger.
  • Possibility to display the log level in the console.
logLevels :  ['debug', 'info', 'warn', 'error', 'fatal']

Option to disable the logger (for using it on PRODUCTION)

isEnabled : false

Install

This project uses node and npm. Go check them out if you don't have them locally installed!

https://www.npmjs.com/package/vuejs-logger

$ npm install vuejs-logger --save-exact

Usage

Below you can find an example of how to use vuejs-logger :

import VueLogger from 'vuejs-logger'

const options = {
    // optional : defaults to true if not specified
    isEnabled: true,
    // required ['debug', 'info', 'warn', 'error', 'fatal']
    logLevel : 'debug',
    // optional : defaults to false if not specified
    stringifyArguments : false,
    // optional : defaults to false if not specified
    showLogLevel : false,
    // optional : defaults to false if not specified
    showMethodName : false,
    // optional : defaults to '|' if not specified
    separator: '|',
    // optional : defaults to false if not specified
    showConsoleColors: false
}

Vue.use(VueLogger, options)
new Vue({
    data() {
        return {
            a : 'a',
            b : 'b'
        }
    },
    created() {
        this.$log.debug('test', this.a, 123)
        this.$log.info('test', this.b)
        this.$log.warn('test')
        this.$log.error('test')
        this.$log.fatal('test')
        externalFunction()
    }
})

function externalFunction() {
   // log from external function
   Vue.$log.debug('log from function outside component.') 
}

screen shot 2017-10-17 at 10 54 05

Maintainers

@justinkames.

Contribute

Feel free to dive in! Open an issue or submit PRs.

vuejs-logger follows the Contributor Covenant Code of Conduct.

License

MIT © Justin Kames

About

Provides customizable logging functionality for Vue.js. Compatible with Vue2.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%