gelf-client
TypeScript icon, indicating that this package has built-in type declarations

0.1.11 • Public • Published

GELF Client

GELF Client for Node.js written in TypeScript. The Client supports TCP and UDP transports.

Install

yarn add gelf-client

Usage

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,
}

Client API

See type definitions.

Connection string

Connection string (DSN) format proto://hostOrIp[:port]/[?[flag[&option=value[&option2=value2]]]}

Options:

  • compress - use zlib compression as flag
  • maxChunkSize - maximum size of a message chunk, default 1440
  • minCompressSize - minimal size of a message to compress, default 1440
  • strict - custom fields strict checks

Package Sidebar

Install

npm i gelf-client

Weekly Downloads

68

Version

0.1.11

License

MIT

Unpacked Size

29.4 kB

Total Files

33

Last publish

Collaborators

  • izatop