https://github.com/izatop/gelf-client
GELF Client for Node.js written in TypeScript
https://github.com/izatop/gelf-client
gelf graylog logging nodejs tcp transport typescript udp
Last synced: about 1 month ago
JSON representation
GELF Client for Node.js written in TypeScript
- Host: GitHub
- URL: https://github.com/izatop/gelf-client
- Owner: izatop
- License: mit
- Created: 2019-11-20T12:06:45.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2023-06-01T14:53:26.000Z (about 3 years ago)
- Last Synced: 2025-11-27T21:34:15.919Z (7 months ago)
- Topics: gelf, graylog, logging, nodejs, tcp, transport, typescript, udp
- Language: TypeScript
- Homepage:
- Size: 38.6 MB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# 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:
```typescript
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:
```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