@therockstorm/graylog
TypeScript icon, indicating that this package has built-in type declarations

1.0.1 • Public • Published

graylog

npm Build Status MIT License Package Size

Tiny typed library to send compressed, chunked log messages to Graylog via GELF.

Installing

npm install @therockstorm/graylog --save

Usage

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<void> => {
  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

Package Sidebar

Install

npm i @therockstorm/graylog

Weekly Downloads

61

Version

1.0.1

License

MIT

Unpacked Size

29.9 kB

Total Files

7

Last publish

Collaborators

  • therockstorm