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

syslog-server-ts

v0.5.2

Published

Syslog Server in TypeScript, With parser

Downloads

249

Readme

NPM version

Syslog Server

A simple and robust Syslog server with Syslog Parser implementation in TypeScript.

Installation

Install the package using npm:

npm install syslog-server-ts

Usage

Here is a basic example demonstrating how to use the SyslogServer class to create a Syslog server that listens for messages on specified ports:

import SyslogServer, { SyslogOptions } from "syslog-server-ts";

const options: SyslogOptions = {
  ports: [514, 515, 516], // Specify the ports you want the server to listen on
  address: '0.0.0.0',
  exclusive: true,
  formatHints: new Map([514, 'rfc5424'], [515, 'LEEF'], [516, 'ELF']),
};

const server = new SyslogServer();

server.onMessage((message) => {
  console.log('Received syslog message:', message);
});

server.onError((error) => {
  console.error('Error occurred:', error);
});

server.onClose(() => {
  console.log('Server closed');
});

server.start(options).catch((error) => { // If you don't specify any option and leave it as black, the server will listen on 514, 0.0.0.0 and exclusice
  console.error('Failed to start server:', error);
});

Blank Example

server.start().catch((error) => { 
    console.error('Failed to start server:', error);
});

API Documentation

SyslogServer Class

Methods

  • start(options: SyslogOptions): Starts the Syslog server with the specified options. Returns a promise that resolves when the server starts successfully.
  • stop(): Stops the Syslog server. Returns a promise that resolves when the server stops successfully.
  • isRunning(): Returns a boolean indicating whether the server is currently running.

Events

  • message: Emitted when a syslog message is received. The message object is passed as an argument to the event handler.
  • error: Emitted when an error occurs. The error object is passed as an argument to the event handler.
  • start: Emitted when the server starts successfully.
  • stop: Emitted when the server stops successfully.

SyslogOptions Type

An object with the following properties:

  • ports: An array of port numbers that the server should listen on.
  • address: The address that the server should bind to.
  • exclusive: A boolean indicating whether the server should have exclusive control over the ports.
  • formatHints: A map of port numbers to format hints for the server to use.

formatHints Type List

  • RFC5424: The format hint for RFC5424.
  • RFC3164: The format hint for RFC3164.
  • LEEF: The format hint for LEEF.
  • JSON: The format hint for JSON.
  • CEF: The format hint for CEF.
  • CLF: The format hint for CLF.
  • ELF: The format hint for ELF.
  • Regex: The format hint for Regex.
    • Example: '\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}'
  • NONE : No format hint

Contributing

Contributions are welcome! Please open an issue or submit a pull request on the GitHub repository.