winstonjs-http-transport

2.0.0 • Public • Published

winstonjs-http-transport

Custom HTTP Transport for winston

NOTE This is experimental code. Do not use in production

Why?

Winston already has a built-in HTTP Transport but it recommends using winstond as a backend which claims to support both HTTP and nssocket

If you already have an API endpoint for logging and looking for a really simple HTTP Transport to directly POST the logs there, you might find this usefull

Usage

import HTTPTransport from 'winstonjs-http-transport'
// OR
const HTTPTransport = require('winstonjs-http-transport')
 
 
logger.add(new HTTPTransport({
    logServer: 'http://your-log-server.com',
    room: 'backend-logs',
    bufferInterval: 1000 // ms
}))

This will POST the logs in the following JSON format

{
    "room": "backend-logs",
    "logs": [
        { "message": "Hello", "level": "info" },
        { "message": "World", "level": "warn" }
    ]
}

to the endpoint http://your-log-server.com/logs every 1000 ms (only if there are logs in that window)

If you want to use this module, I encourage you to see the code (it's just 27 lines) before and make any required changes as it is currently not optimized enough

Dependencies (3)

Dev Dependencies (0)

    Package Sidebar

    Install

    npm i winstonjs-http-transport

    Weekly Downloads

    2

    Version

    2.0.0

    License

    ISC

    Unpacked Size

    2.76 kB

    Total Files

    3

    Last publish

    Collaborators

    • akashmugu