1.1.1 • Published 8 years ago
vogger v1.1.1
Vogger
About
A logging module that works on both Node.js and Browser/Vue.js environment.
Usage
npm i vogger
Node.js
const vogger = require('vogger')
const logger = vogger()
logger.info('Logger has been initialized')
Browser / Webpack
import vogger from 'vogger'
const logger = vogger()
logger.info('Logger has been initialized')
Vue.js
import Vue from 'vue'
import { VoggerPlugin } from 'vogger'
Vue.use(VoggerPlugin)
new Vue({
el: '#app',
created () {
this.$logger.info('App has been initialized')
}
})
Configuration
Level
This controls the minimum log level the logger will write.
Available values are false
, 'silly'
, 'debug'
, 'verbose'
, 'info'
, 'warn'
, 'error'
. If you use false
then the logger will ignore everything.
Default value for this is false
if process.env.NODE_ENV
is set to production,
otherwise debug
.
Timestamp
A boolean whether the logger should prepend the messages with a timestamp.
Default value for this is false
Colors
A boolean whether the logger should print the log level in colors. Note that this is ignored with used in the browser environment.
Default value for this is true
Example
const logger = vogger({
level: process.env.NODE_ENV === 'production' ? 'error' : 'silly',
timestamp: true,
colors: false
})
// Or
Vue.use(VoggerPlugin, {
level: process.env.NODE_ENV === 'production' ? false : 'silly',
timestamp: false
})
Testing
To execute the tests and the linting then execute npm test
.