nuxt-log

0.1.0 • Public • Published

nuxt-log

A logger module for Nuxt.js using vuejs-logger

Setup

  • Add nuxt-log dependency using yarn or npm to your project
  • Add nuxt-log to modules section of nuxt.config.js
const logOptions = {
  // 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
}
 
{
  modules: [
   ['nuxt-log', logOptions],
  ]
}

Usage

You can use $log in almost any context using app.$log or this.$log.

See vuejs-logger official docs for more usage information.

export default {
  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');
  },
};

License

MIT License

Copyright (c) webcore-it

Package Sidebar

Install

npm i nuxt-log

Weekly Downloads

64

Version

0.1.0

License

MIT

Unpacked Size

3.52 kB

Total Files

6

Last publish

Collaborators

  • webcore-it