Provides Customizable Logging Functionality for Vue.js | vuejs-logger

vuejs-logger is to provide customizable logging functionality for Vue.js. Compatible with Vue2.

vue logger plugin, vuejs logging to file, vue 3 logging, vuejs logger example, vue log viewer, vue log4j, how to log data in vue js, client side logging vue

vuejs-logger is a tool that enables configurable logging for Vue applications. Features include :

  • Output restriction based on selected loglevel.
  • Automatically JSON.stringify() the (reactive) properties passed to the logger.
  • Configurable options to customize output for log messages.
  • Colored console messages for $log.warning, $log.error and $log.fatal.

How to make use of it:

Install & Download:

$ npm install vuejs-logger --save-exact

Usage

import VueLogger from 'vuejs-logger';
const isProduction = process.env.NODE_ENV === 'production';
 
const options = {
    isEnabled: true,
    logLevel : isProduction ? 'error' : 'debug',
    stringifyArguments : false,
    showLogLevel : true,
    showMethodName : true,
    separator: '|',
    showConsoleColors: true
};

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.');
}

Properties

NameRequiredTypeDefaultDescription
isEnabledfalseBooleantrueEnables the vuejs-logger plugin, a useful toggle for production/development.
logLevelfalseString‘debug’Choose between [‘debug’, ‘info’, ‘warn’, ‘error’, ‘fatal’]. Read production tips.
stringifyArgumentsfalseBooleanfalseIf true, all input will go through JSON.stringify(). Useful when printing reactive properties.
showLogLevelfalseBooleanfalseIf true, the loglevel will be shown.
showMethodNamefalseBooleanfalseIf true, the method name of the parent function will be shown in the console.
separatorfalseString‘ l ‘The separator between parts of the output (sees screenshot.
showConsoleColorsfalseBooleanfalseIf true, enables console.warn, console.fatal, console.error for corresponding loglevels.

customizable logging, vuejs-logger Plugin/Github


See Demo And Download

Official Website(justinkames): Click Here

This superior jQuery/javascript plugin is developed by justinkames. For extra advanced usage, please go to the official website.

Related Posts

Cookie-Consent-Using-Bootstrap

How to Create a Simple Cookie Banner Consent Using Bootstrap 4

Cookie Consent Popup Javascript – Quick and simple tutorial for creating a simple Bootstrap cookie banner. If you have a website or blog with people visiting or…

Create-HTML-Terminals

Create Custom HTML Terminals With Pure JavaScript | shell.js

Custom HTML Terminals is A JavaScript library to create HTML terminals on web pages. The shell js JavaScript library offers a straightforward method to create Ubuntu, OS X,…

Bootstrap-Alert-Bootbox

Bootstrap Alert, Confirm, and Flexible Dialog Boxes | Bootbox

Bootbox.js is a small JavaScript library that allows you to create programming dialogs using Bootstrap templates, without having to worry about creating, managing, or removing any required…

Slider-fg-carousel

An Accessible Touch-enabled Slider Web Component | fg-carousel

fg-carousel Slider – A simple & modern slider web component to create versatile, accessible, touch-enabled picture carousels utilizing CSS scroll snap, Custom Element, and Intersection Observer API….

Tags-Input-Component

A Lightweight and Efficient Tags Input Component in Vanilla JS | tagify

tagify transforms an input field or textarea into a tags component, in an easy and customizable way, with great performance and a small code footprint, full of…

copy-to-clipboard-javascript

A Lightweight Library to Copy Text to Clipboard | CopyJS

CopyJS is a lightweight JavaScript library that allows you to copy plain text or HTML content to the clipboard. Must Read: Tiny Library for Copy Text In…