https://github.com/therockstorm/graylog
Tiny typed library to send compressed, chunked log messages to Graylog via GELF.
https://github.com/therockstorm/graylog
aws-lambda gelf graylog graylog2 log logger logging tools typescript udp
Last synced: 8 months ago
JSON representation
Tiny typed library to send compressed, chunked log messages to Graylog via GELF.
- Host: GitHub
- URL: https://github.com/therockstorm/graylog
- Owner: therockstorm
- License: mit
- Created: 2019-10-22T23:04:29.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2020-11-09T12:48:09.000Z (over 5 years ago)
- Last Synced: 2025-03-15T16:19:15.031Z (about 1 year ago)
- Topics: aws-lambda, gelf, graylog, graylog2, log, logger, logging, tools, typescript, udp
- Language: TypeScript
- Homepage:
- Size: 1.62 MB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# graylog
[](https://www.npmjs.com/package/@therockstorm/graylog)
[](https://travis-ci.org/therockstorm/graylog)
[](https://github.com/therockstorm/graylog/blob/master/LICENSE)
[](https://bundlephobia.com/result?p=@therockstorm/graylog)
Tiny typed library to send compressed, chunked log messages to Graylog via GELF.
## Installing
```shell
npm install @therockstorm/graylog --save
```
## Usage
```javascript
import { Graylog } from "@therockstorm/graylog"
import { name } from "../package.json"
// Configure log to include defaults in each message
const log = new Graylog({
host: "localhost", // default
port: 12201, // default
defaults: {
host: name, // defaults to os.hostname()
myCustomField: { hello: { there: "world" } }
}
})
// Log logger errors to console
log.on("error", err => console.error("@therockstorm/graylog error", err))
const app = async (): Promise => {
log.info("Hello, info.")
// Include new defaults in each message
log.addDefaults({ requestId: "myId" })
log.warning("Hello, warning.", { facility: "MyApp" })
log.error("Hello, error.", new Error("boom"))
// Wait for messages to send and close Graylog connection
await log.close()
}
app()
```
## License
MIT © [Rocky Warren](https://www.rocky.dev)