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

@axai/winston-cloudwatch-logger-config

v6.0.4

Published

This is currently a pre-release version, deployed for testing.

Downloads

31

Readme

winston-cloudwatch-logger-config

A simple and configurable Winston logger setup for Node.js applications, supporting AWS CloudWatch integration. This library allows you to manage multiple log streams dynamically via a JSON configuration file.

Features

  • Dynamic Configuration: Easily configure log streams and settings via a JSON file.
  • AWS CloudWatch Integration: Seamlessly logs messages to AWS CloudWatch.
  • Multiple Log Streams: Supports multiple log streams for different services or components.
  • JSON Logging Format: Logs messages in JSON format for easy parsing and analysis.

Installation

Install the library using npm:

npm install @axai/winston-cloudwatch-logger-config

Configuration

Create a .logger-config.json file in the root of your project. This file will contain your log group name, log streams, and AWS region.

Example logger-config.json

{
    "application": {
      "name": "yourAppName",
      "version": "0.1.0",
      "awsRegion": "eu-west-2"
    },
    "logStreams": [
      {
        "logGroupName": "yourLogGroupName",
        "logStreamName": "application",
        "level": "info",
        "type": "cloudwatch"
      },
      {
        "logGroupName": "yourLogGroupName",
        "logStreamName": "error",
        "level": "error",
        "type": "cloudwatch"
      }
    ]
  }
  • logGroupName: The name of the CloudWatch log group, or the special values "file" or "console" to log to a file or the console.
  • logStreams: An array of log stream configurations, each with a name and level.
  • awsRegion: The AWS region where your CloudWatch log group is located.
  • level: The log level for the stream (e.g., "error", "info", "debug").
  • path: The path to the log file when logging to a file.

Usage

Import the logger object from the library and use the loggers for different services or components based on the configured log streams.

Ensure your logger-config.json is in the root directory of your project.

Use the loggers in your application:

import loggers from "winston-cloudwatch-logger-config";

logger.forEach((logger) => {
  logger.info("This is an info message");
  logger.error("This is an error message");
});

loggers.yourLogGroupName.info("This is a CloudWatch log message");

Environment Variables

Alternatively, if it is more convenient for your environment, you can set AWS credentials using environment variables, which will be used in the event that they are not specified in the logger-config.json file:

Additional Notes

  • The loggers object will contain a logger for each configured log stream.
  • Ensure your AWS credentials and region are correctly set in the JSON file to allow proper logging to CloudWatch.
  • The JSON configuration approach allows for easy management and flexibility, especially when dealing with multiple log streams and dynamic environments.

Release Notes (0.2.0)

The loggers object now includes a LogFactory method which creates logs in a given format.

Usage example:

loggers.yourLogGroupName.info(loggers.LogFactory("info", { message: "This is an info message" }););

License

Copyright AX-AI LTD 2024. ISC License. See LICENSE file for details.