loglevel-plugin-server

1.0.7 • Public • Published

loglevel-plugin-server

Plugin for sending logs to the remote server

Installation

> npm install loglevel-plugin-server --save

Usage

loglevelPlugin(loglevel, options);

Parameters

loglevel - the root logger, imported from loglevel package

options - plugin config object

options parameter type description default value
url string url to log server http://localhost:8080/log
callOriginal boolean true call original loglevel method (console.log)
level string trace loglevel level (trace, debug, info, warn, error). See loglevel documentation
format function see below function for formatting message before sending to the server

Default format function

const format = ({message, methodName, logLevel, loggerName}) => {
    return JSON.stringify({
        message: message,
        level: {
            label: (methodName || '').toUpperCase(),
            value: logLevel
        },
        logger: loggerName || '',
        timestamp: new Date().toISOString()
    });
};

ES6 usage example

import loglevelPlugin from '../loglevel-plugin-server/lib/loglevel-plugin-server.min';
import loglevel from 'loglevel';
 
 
 
const options = {
    url: 'http://localhost:8080/'
};
loglevelPlugin(loglevel, options);
loglevel.info('it is easy to use loglevel-plugin-server');

License

This software is distributed under an MIT licence.

Copyright 2017 © Zoreslav Goral

Package Sidebar

Install

npm i loglevel-plugin-server

Weekly Downloads

1

Version

1.0.7

License

MIT

Last publish

Collaborators

  • zoreslavgoral