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

log-aggregator

v1.0.3

Published

"Log-aggregator" is a Node.js package that provides a simple way to aggregate logs from multiple sources. Whether you're using local file logging, a third-party logging service, or a cloud-based logging system like AWS CloudWatch, "log-aggregator" allows

Downloads

5

Readme

Log Aggregator

Log-aggregator is a Node.js package that provides a simple way to aggregate logs from multiple sources. Whether you're using local file logging, a third-party logging service, or a cloud-based logging system like AWS CloudWatch, log-aggregator allows you to combine all your logs into a single, centralized location. This makes it easier to search and analyze your logs, identify trends and issues, and troubleshoot problems. With log-aggregator, you can improve your application's logging functionality and gain valuable insights into how your application is performing.

Installation

 npm install log-aggregator

Usage

Initialization

Initialize the log aggregator by calling the initialize function with a configuration object. The configuration object must specify the logging system to use (graylog or cloudwatch) and any required configuration options.

const { initialize } = require('log-aggregator');

initialize({
  loggingSystem: 'graylog',
  graylogHost: 'localhost',
  graylogPort: 12201,
  connection: 'lan',
  maxChunkSizeWan: 1420
});

const { initialize } = require('log-aggregator');

initialize({
  loggingSystem: 'cloudwatch',
  region: 'us-west-2',
  accessKeyId: 'your-access-key',
  secretAccessKey: 'your-secret-key'
});

Logging

Once the log aggregator is initialized, you can log messages using the logMessage function. The function takes a message string and an optional metadata object.

const { logMessage } = require('log-aggregator');

logMessage('This is a log message', { foo: 'bar' });

Supported Logging Systems

Graylog

The log aggregator supports logging to a Graylog server using the GELF protocol. To log to a Graylog server, initialize the library with the graylog logging system and specify the graylogHost and graylogPort configuration options.

const { initialize } = require('log-aggregator');

initialize({
  loggingSystem: 'graylog',
  graylogHost: 'localhost',
  graylogPort: 12201,
  connection: 'lan',
  maxChunkSizeWan: 1420
});

AWS CloudWatch Logs

The log aggregator also supports logging to AWS CloudWatch Logs. To log to AWS CloudWatch Logs, initialize the library with the cloudwatch logging system and specify the region, accessKeyId, and secretAccessKey configuration options.

const { initialize } = require('log-aggregator');

initialize({
  loggingSystem: 'cloudwatch',
  region: 'us-west-2',
  accessKeyId: 'your-access-key',
  secretAccessKey: 'your-secret-key'
});

Typescript

import { initialize, logMessage, LoggingConfig, GraylogConfig, CloudWatchConfig } from 'log-aggregator';

const myGraylogConfig: GraylogConfig = {
  graylogHost: 'localhost',
  graylogPort: 12201
};

const myCloudwatchConfig: CloudWatchConfig = {
  region: 'us-east-1',
  accessKeyId: 'my-access-key',
  secretAccessKey: 'my-secret-key'
};

const myLoggingConfig: LoggingConfig = {
  loggingSystem: 'graylog',
  graylogConfig: myGraylogConfig
};

initialize(myLoggingConfig);

logMessage('This is a log message', { foo: 'bar', baz: 123 });

The initialize function takes a LoggingConfig object as its parameter, which specifies the logging system to use and its configuration. The logMessage function takes a string message and an optional metadata object of type Record<string, any>.

Note that the library has been updated to allow metadata to accept a string, array, object, or array of objects.

Contributing

Contributions are welcome! Please see CONTRIBUTING.md for more information.

License

MIT