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

splunk-logger

v2.0.11

Published

An advance splunk logger for nodejs

Downloads

196

Readme

splunk-logger

splunk-logger is a robust and efficient JavaScript library designed to streamline the process of sending logs to Splunk. It provides a simple yet powerful interface for log management.

Installation

Use the package manager npm to install splunk-logger.

npm install splunk-logger

Usage

import { SplunkLogger } from "splunk-logger";

const logger = new SplunkLogger({
    token: "your token",
    domain: "your splunk host",
});

logger.info('server is running on port 3000');

Use with Winston logger

import * as winston from "winston";
import { SplunkLogger } from "splunk-logger";
import { SplunkWinstonTransport } from "splunk-logger";

const logger = winston.createLogger({
    transports: [
        new winston.transports.Console(),
        new SplunkWinstonTransport({
            token: "your token",
            domain: "your splunk host",
        })
    ]
});

Full options object

const options = new SplunkLoggerOptions({
    domain: "localhost",
    port: 8088,
    tls: false,
    token: "00000000-0000-0000-0000-000000000000",
    shouldPrintLogs: true,
    isBatchingEnabled: false,
    batchOptions: {
        batchSize: 500, 
        queueSizeLimit: 10000 
    },
    exceptionOnFailure: false
});

const logger = new SplunkLogger(options)

You can expect the console to print:

12:31:12 - INITIAL - Logger initialed

In case of error, please check if your Splunk settings and make sure your token and address are correct.

BatchMode Overview

What is BatchMode?

BatchMode is an advanced feature in SplunkLogger designed to optimize logging performance in high-traffic environments. This mode enables the batching of multiple log entries, which are then sent to Splunk in a single HTTP request. This method is highly efficient and beneficial for applications where minimizing the impact on the event loop and reducing network traffic is crucial.

Benefits

  • Batched Log Entries: BatchMode batches a specified number of log entries, which are then sent as a single HTTP request. This significantly reduces the total number of HTTP requests made to Splunk.
  • Reduced Event Loop Activity: By lowering the frequency of HTTP requests, BatchMode minimizes the workload on the event loop and network usage, leading to improved application performance.
  • Customizable Queue Size: Users have the flexibility to set a limit on the queue size, which helps in managing memory usage effectively and preventing potential memory leaks.

Recommended Usage

BatchMode is particularly useful for applications that generate a large volume of logs and require efficient log management. It should be configured with a careful balance between performance enhancement and resource utilization.

Configuration

To enable and configure BatchMode in your application set:

    isBatchingEnabled: true

To enable to receive exceptions when sending data to splunk fails set:

    exceptionOnFailure: true

Log levels

  • info
  • warn
  • error
  • fatal
  • debug
  • raw (for sending raw data directly to Splunk)

License

MIT