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

@maxpp/processlogger

v2.0.7

Published

A class function for structured logging of processes from start to finish.

Downloads

115

Readme

Process Log

A logging function for used to log steps of a process.

  • The ideal is to leave the logs in your code and enable or disable them as needed by changing the log property in your Log.start() call.
  • This is useful to quickly log the flow of a process when developing or debugging, and other developers can easily enable or disable the logs to see the process running.

Features:

  • Start and end new process logs with a name.
  • Easily enable or disable logging for a specific process.
  • Clearly logs steps of a process and logs the duration of the process.
  • Proces logs are colored for easy identification. The colors are randomly assigned per process, or you can set a specific color per process.

Installation

  npm i @maxpp/processlogger

Import

  import { Log } from "@maxpp/processlogger";

Usage

Log.start({ name: "myProcess", log: true }); // Start the process by naming it and decide if it should log.
Log.log.myProcess("Message to log"); // Log a message within the process.
Log.end.myProcess(); // Stop the process and log the duration.

Example

Log.start({ name: "myProcess", log: true }); // Start the process. Set log to false to disable logging.
Log.log.myProcess("Creating data source"); // Log a message
Log.log.myProcess("SUCCESS - Fetched data source template");
Log.log.myProcess("Parsed data source template");
Log.end.myProcess(); // End the process and log the duration

Example output

----- START - MYPROCESSNAME -----
myProcess: Creating data source
myProcess: SUCCESS - Fetched data source template /process.ts:12
myProcess: SUCCESS - Fetched data set template /process.ts:12
myProcess: Parsed data source template /process.ts:12
myProcess: Parsed data set template /process.ts:12
----- END - MYPROCESSNAME - Completed in 1.46 seconds. -----

Example log output

This example shows the process logs of 5 processes that run in sequence. Each process is asigned a random color when it starts which makes it easier to distinguish the logs of each process.

  • updated_project_blocks (This operation logged in blue and completed in 0.062 seconds.)
  • created_project_validation (This operation logged in salmon and did not complete.)
  • update_project_queue (This operation logged in purple and did not complete.)
  • update_project_s3_files (This operation logged in fushia and completed in 0.954 seconds.)
  • get_content_from_s3 (This operation logged in green and completed in 0.494 seconds.)

Disable a process log

Set the log property to false to disable logging for a specific process. This way you can leave the logs in your code and enable them as needed.

Log.start({ name: "datasource", log: false }); // Set log to false to disable logging.

Set a specific color for a process

You can set a specific hex color for a process by passing a color property in the start method.

Log.start({ name: "datasource", log: true, color: "#2a9d8f" }); // Set a specific color for the process.

V2 Changes

  • The process name is now added after the .log or .end. Example: Log.log.myProcess("Message to log"); or Log.end.myProcess();
  • The function can now be imported with Log instead of ProcessLog.
  • The log messages now display the file and line number where the log was called.
  • Optional color property to set a specific color for a process.

Recommended use

  • Add clear operation logs for each of your processes and leave them in your code.
  • Once implemented, disabled the operation logs by setting the log property to false.
  • During development or debugging, other team members can easily enable the logs to immediately see the process runnign and identify any issues.

Dependencies

  • chalk - For colored console output.