GELF Client for Node.js written in TypeScript. The Client supports TCP and UDP transports.
yarn add gelf-client
Simple usage with UDP transport:
import GELFClient, {Level} from "gelf-client";
const client = GELFClient.factory("udp://localhost:12201/?compress", {app: "app"})
.clone({pid: process.pid});
client.send({
level: Level.ERROR,
message: "Short message",
description: "Stack trace or something else",
// custom fields
request_id: uuid(),
user_id: 1,
});
This code will send these json:
{
"version": "1.1",
"host": "app",
"short_message": "Short message",
"full_message": "Stack trace or something else",
"timestamp": 12345678,
"level": 3,
"_user_id": 42,
"_request_id": "a36f0d30-0b90-11ea-8d71-362b9e155667",
"_pid": 123,
}
See type definitions.
Connection string (DSN) format proto://hostOrIp[:port]/[?[flag[&option=value[&option2=value2]]]}
Options:
compress
- usezlib
compression as flagmaxChunkSize
- maximum size of a message chunk, default 1440minCompressSize
- minimal size of a message to compress, default 1440strict
- custom fields strict checks