New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@navigraph/graylog-client

Package Overview
Dependencies
Maintainers
3
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@navigraph/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.

  • 0.1.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
3
Created
Source

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 @navigraph/graylog-client

NPM

npm install @navigraph/graylog-client

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

PropertyTypeDescriptionRequired
serverstringThe endpoint to which the requests should be sent, including protocol.yes
sourcestringThe client from which the logs are sent.yes
idGeneratorfunctionA 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.

MethodSeverityDescriptionCondition
emergencyEmergencySystem is unusableA panic condition. [1]
alertAlertAction must be taken immediatelyA condition that should be corrected immediately, such as a corrupted system database. [1]
criticalCriticalCritical conditionsHard device errors. [1]
errorErrorError conditions
warningWarningWarning conditions
noticeNoticeNormal but significant conditionsConditions that are not error conditions, but that may require special handling. [1]
infoInformationalInformational messages
debugDebugDebug-level messagesMessages 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.

ParameterTypeDescriptionRequired
messagestringThe short (summary) message to display in Graylog.yes
extrasobjectAny 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

Keywords

FAQs

Package last updated on 22 Jul 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc