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

rpulogger

v1.0.19

Published

A CDP Library built for Rug Pad USA

Downloads

8

Readme

RPU Logger Documentation

Overview

RPU Logger is a TypeScript-based logging utility designed for Node.js environments. It provides a structured and validated way to log information, errors, and other data, ensuring consistency and reliability in log output.

Features

  • Schema Validation: Utilizes Joi for log data validation, ensuring that all logs conform to a predefined schema.
  • Flexible Log Data: Supports a variety of log data, including error messages, stack traces, and additional custom data.
  • Remote Logging: Capable of sending log data to a remote server for centralized logging.

Installation

To install RPU Logger, use npm:

npm install rpulogger

Usage

Importing RPU Logger

import { createLog, LogData } from "rpu-logger";

Creating a Log Entry

To create a log entry, you need to provide an object that matches the LogData interface.

const logData: LogData = {
  name: "ExampleLog",
  source: "exampleSource",
  status: 200, // HTTP status code for example
  userMessage: "This is a user message",
  logtoken: "your-log-token",
  // Optional fields
  errorMessage: "Error occurred here",
  stack_trace: "Error stack trace",
  additional_data: { additional: "info" },
};

createLog(logData)
  .then(() => {
    console.log("Log created successfully");
  })
  .catch((error) => {
    console.error("Log creation failed", error);
  });

Log Data Schema

The log data must conform to the following schema:

  • name: string (required) - Name of the log entry.
  • source: string (required) - Source of the log.
  • status: number (required) - Status code (e.g., HTTP status codes).
  • userMessage: string (required) - A message suitable for user display.
  • errorMessage: string (optional) - Detailed error message.
  • stack_trace: string | object (optional) - Stack trace of the error.
  • additional_data: object (optional) - Any additional data.
  • logtoken: string (required) - A token to authenticate or identify the log entry.

Validating Log Data

The createLog function internally validates the log data against the schema. If the data is invalid, it throws an error.

Sending Log Data

The createLog function sends the validated log data to a remote server. Ensure to replace the URL in the addLogEntry function with your logging endpoint.

Configuration

  • The api key must be set under RUGPADWEB_LOG_TOKEN and NEXT_PUBLIC_RUGPADWEB_LOG_TOKEN
  • Schema validation rules can be adjusted in the logSchema definition as per your requirements.

Best Practices

  • Always catch and handle errors when creating logs.
  • Ensure sensitive information is not logged.
  • Update the logging endpoint to a secure and reliable server.

For more information or support, visit the RPU Logger Repository.

(Note: The above link is a placeholder, replace with the actual URL to your repository/documentation.)