winston-warp10
TypeScript icon, indicating that this package has built-in type declarations

1.0.4 • Public • Published

ISC License Test Status

winston-warp10

A Warp10 transport for Winston.

Installation

  $ npm install winston
  $ npm install winston-warp10

Basic usage

var winston = require('winston');
var warp10 = require('winston-warp10').Warp10;
  
/* Check https://sandbox.senx.io to get your 
*  <writeToken> for using Warp10 sandbox.
*  Or use credentials from your own Warp10 instance
*/ 
var options = {
    writeToken: "<writeToken>",
    protocol: "https",    
    host: "sandbox.senx.io",
    className: "test"
}

winston.add(new warp10(options));
  
/* Insert a new entry in the GTS 'test{}' with value equals to 'logs' */
winston.info("logs");

The Warp10 transport takes the following options. writeToken, protocol, host and className are required :

  • level: Level of messages transport will log, default : info.
  • silent: Boolean flag indicating whether to suppress output, default : false.
  • name: Name and identifier of the transport instance, default : Warp10.
  • writeToken: Warp10 writing token.
  • protocol: http or https or ws or wss.
  • host: Host. Can be sandbox : "sandbox.senx.io" therefore you can only use https or wss protocol. Or it can be any host address of private Warp10 instance.
  • port: Port of your Warp10 instance. Empty for Warp10 sandbox.
  • className: Class name of the GTS you want to send your data to.
  • labels: Labels of the GTS, default : empty.
  • timestamp: Timestamp, default : use Warp10 own timestamp.
  • Latitude: Latitude coordinate.
  • Longitude: Longitude coordinate.
  • Elevation: Elevation above sea level.
  • KeepWSAlive: Keep alive websocket connection, default true. Useless in http or https protocol.

Advanced usage

In the example below, we create our own winston logger. We add the warp10 transport, then we will be able to dynamically set attributes like latitude or labels even after the creation of the transport.

const winston = require('winston');
const warp10Transport = require('winston-warp10').Warp10;

const customLogger = winston.createLogger({
    /* options 
    *  You can set various options for your own custom
    *  logger, see Winston documentation.
    */
    transports: [
        new warp10Transport({
            name: "My Warp10 transport",
            writeToken: "<writeToken>",
            protocol: "https",
            host: "sandbox.senx.io",
            className: "test",
            labels: "position=Paris"
        }),
    ] 
})

/* Insert a new entry in the GTS 'test' with label 'position=Paris' and value equals to 'Hello from Paris', at Eiffel Tower's geographic position */
customLogger.transports[0].latitude = "48.86";
customLogger.transports[0].longitude = "2.29"
customLogger.info("Hello from Paris");

Changelog

Current Version: 1.0.4 — Released 2019-08-27

  • Fix error.response undefined in post request

Version: 1.0.3 — Released 2019-08-22

  • Correctly escape special chars in string value

Version: 1.0.2 — Released 2019-07-31

  • Update axios.post error message

Version: 1.0.1 — Released 2019-07-15

  • Handle promise rejection warning

Version: 1.0.0 — Released 2019-07-03

  • Introducing the warp10 Transport for winston.

License

winston-warp10 is freely distributable under the terms of the ISC license.

Author: Pierre-Antoine Moitier

Contributors: Erwan Géréec

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
1.0.40latest

Version History

VersionDownloads (Last 7 Days)Published
1.0.40
1.0.31
1.0.20
1.0.10
1.0.00

Package Sidebar

Install

npm i winston-warp10

Weekly Downloads

1

Version

1.0.4

License

ISC

Unpacked Size

15.7 kB

Total Files

6

Last publish

Collaborators

  • pa_moitier