1.0.7 • Published 6 years ago

loglevel-plugin-server v1.0.7

Weekly downloads
11
License
MIT
Repository
github
Last release
6 years ago

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 parametertypedescriptiondefault value
urlstringurl to log serverhttp://localhost:8080/log
callOriginalbooleantruecall original loglevel method (console.log)
levelstringtraceloglevel level (trace, debug, info, warn, error). See loglevel documentation
formatfunctionsee belowfunction 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

1.0.7

6 years ago

1.0.6

6 years ago

1.0.5

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago