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

logginglibraryformerndevdashboard

v3.2.0

Published

The Logging Library for the DevDashboard is designed to provide robust logging capabilities throughout the application. It focuses on capturing detailed logs with custom decorators that handle both success and error states efficiently, and it supports han

Downloads

249

Readme

Logging Library

The Logging Library for the DevDashboard is designed to provide robust logging capabilities throughout the application. It focuses on capturing detailed logs with custom decorators that handle both success and error states efficiently, and it supports handling of circular references in logged data.

Features

  • Logging Decorator: Enhances functions with automatic logging of input, output, exceptions, and other operational metadata.
  • Circular Reference Handling: Utilizes a custom JSON stringification method to safely log data structures that include circular references.
  • File Logging: Automatically writes logs to a JSON file, which can be used for auditing and debugging purposes.

Installation

Ensure you have Node.js installed on your system to use the Logging Library. Follow these steps to set up the library in your project:

  1. Clone the DevDashboard repository if you haven't already:

    git clone https://github.com/yourgithub/devdashboard.git
    cd DevDashboard/loggingLibrary
    npm install

Usage

The logDecorator can be imported into your Node.js modules to enhance any function with logging capabilities. Here's how to use it:

import { logDecorator } from './src/logging.js';

const exampleFunction = async (data) => {
    return "Processing complete";
};

const options = {
    expectedInput: "Sample data",
    expectedOutput: "Processing complete",
    criticality: "High",
    description: "Example function for demonstration",
    environment: process.env.NODE_ENV || "development",
};

const decoratedFunction = logDecorator(exampleFunction, options);

// Use the decorated function as normal
decoratedFunction("Sample data").then(console.log).catch(console.error);

Logging Decorator Details

The logging decorator wraps any asynchronous function, capturing and logging the following information:

  • Function Name: Automatically captured from the function it decorates.
  • Timestamp: The time at which the function was called.
  • Expected and Actual Input/Output: Logs what inputs were received and what outputs were produced.
  • Criticality and Description: Custom descriptions and criticality levels for better understanding of log entries.
  • Environment: The environment in which the function is running, typically development, staging, or production.
  • Status: Indicates success or error states.
  • Exceptions: Captures any exceptions thrown by the function.
  • Sub-functions: Allows for nesting logs of other functions called within the decorated function.

Testing

To run tests and ensure the logging functionality works as expected:

npm test

This will execute predefined test cases that verify the decorator handles various scenarios correctly, including proper function enhancement, error handling, and circular reference management.

Contributing

Contributions to enhance or expand the logging library are welcome. Please ensure to follow standard coding practices and add tests for new features.

License

Distributed under the MIT License. See LICENSE for more information.

Contact

Project Link: https://github.com/mwegter95/dev-dashboard