npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

graylog-client

v0.1.0

Published

This library was created in order to easily integrate Graylog into a JS client by handling the requests in GELF format for you.

Downloads

5

Readme

graylog-client

This library was created in order to easily integrate Graylog into a JS client by handling the requests in GELF format for you.

Requirements

In order to make use of the library, your Graylog instance needs to be configured to handle the GELF HTTP input.

Installation

Yarn

yarn add https://github.com/Navigraph/graylog-client.git

NPM

npm install https://github.com/Navigraph/graylog-client.git

Usage

Simple

import GraylogClient from 'graylog-client';

const glc = new GraylogClient({
  server: 'https://log.example.org',
  source: 'sample-app',
});

glc.info('An informative message.');
glc.warning('Something is about to happen!');

Advanced

import GraylogClient from 'graylog-client';
import { v4 as uuid } from 'uuid';

interface GraylogExtras {
  facility: string;
  stack: string;
}

const glc = new GraylogClient<GraylogExtras>({
  server: 'https://log.example.org',
  source: 'sample-app',
  idGenerator: uuid,
});

glc.error('An error ocurred in the pizza component!', {
  facility: 'Pizza',
  stack: '* stack trace *',
});

Constructor

| Property | Type | Description | Required | | ----------- | -------- | ----------------------------------------------------------------------------- | -------- | | server | string | The endpoint to which the requests should be sent, including protocol. | yes | | source | string | The client from which the logs are sent. | yes | | idGenerator | function | A generator function that returns a string to use as ID for each log request. | no |

Typescript

If typescript is used, an optional type generic may be passed to the constructor. This can be used to type the extra information sent with each request (see the Advanced Example for an example implementation), but is not required.

Available methods

The GraylogClient contains multiple convenience methods mapping directly towards syslog's severity levels.

| Method | Severity | Description | Condition | | --------- | ------------- | --------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | emergency | Emergency | System is unusable | A panic condition. [1] | | alert | Alert | Action must be taken immediately | A condition that should be corrected immediately, such as a corrupted system database. [1] | | critical | Critical | Critical conditions | Hard device errors. [1] | | error | Error | Error conditions | | | warning | Warning | Warning conditions | | | notice | Notice | Normal but significant conditions | Conditions that are not error conditions, but that may require special handling. [1] | | info | Informational | Informational messages | | | debug | Debug | Debug-level messages | Messages that contain information normally of use only when debugging a program. [1] |

Each method may be called with two parameters in accordance with the specification below.

| Parameter | Type | Description | Required | | --------- | ------ | ---------------------------------------------------------------------------------------------------------------------------------------------------- | -------- | | message | string | The short (summary) message to display in Graylog. | yes | | extras | object | Any extra information, not including the source client. This object may be typed using a generic in the constructor, see Constructor. | no |

Contributing

For guidelines and useful information, please see CONTRIBUTING.md

License

MIT