项目作者: izatop

项目描述 :
GELF Client for Node.js written in TypeScript
高级语言: TypeScript
项目地址: git://github.com/izatop/gelf-client.git
创建时间: 2019-11-20T12:06:45Z
项目社区:https://github.com/izatop/gelf-client

开源协议:MIT License

下载


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:

  1. import GELFClient, {Level} from "gelf-client";
  2. const client = GELFClient.factory("udp://localhost:12201/?compress", {app: "app"})
  3. .clone({pid: process.pid});
  4. client.send({
  5. level: Level.ERROR,
  6. message: "Short message",
  7. description: "Stack trace or something else",
  8. // custom fields
  9. request_id: uuid(),
  10. user_id: 1,
  11. });

This code will send these json:

  1. {
  2. "version": "1.1",
  3. "host": "app",
  4. "short_message": "Short message",
  5. "full_message": "Stack trace or something else",
  6. "timestamp": 12345678,
  7. "level": 3,
  8. "_user_id": 42,
  9. "_request_id": "a36f0d30-0b90-11ea-8d71-362b9e155667",
  10. "_pid": 123,
  11. }

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