2.0.0 • Published 6 years ago
winstonjs-http-transport v2.0.0
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