https://github.com/gzoreslav/loglevel-plugin-server
Plugin for sending logs to the remote server
https://github.com/gzoreslav/loglevel-plugin-server
logging loglevel loglevel-plugin remote
Last synced: 19 days ago
JSON representation
Plugin for sending logs to the remote server
- Host: GitHub
- URL: https://github.com/gzoreslav/loglevel-plugin-server
- Owner: gzoreslav
- License: mit
- Created: 2017-11-28T10:24:55.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2017-11-28T14:17:48.000Z (over 8 years ago)
- Last Synced: 2026-05-09T09:52:30.407Z (about 2 months ago)
- Topics: logging, loglevel, loglevel-plugin, remote
- Language: JavaScript
- Homepage:
- Size: 19.5 KB
- Stars: 1
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# loglevel-plugin-server
Plugin for sending logs to the remote server
## Installation
```shell
> npm install loglevel-plugin-server --save
```
## Usage
```javascript
loglevelPlugin(loglevel, options);
```
### Parameters
`loglevel` - the root logger, imported from [loglevel](https://github.com/pimterry/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*
```javascript
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
```javascript
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