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

@prakhartandon_org/logm

v0.1.3

Published

Logging & Monitoring for Plugin Environments, where console.logs aren't displayed with complete context. Also supports sending logs to any server (now with batching).

Downloads

14

Readme

logM v0.1.3 (beta)

npm package Visitors

Logging & Monitoring Package that comes with a log-location script, useful for plugin/extensions environments where actual line numbers aren't accesible. Log Batching for production. In prod mode, all logs will be pushed in an array and sent to the server in batches after you call the flush method. Sample Usecase: Logging & Monitoring in Figma Plugins.

Install

npm install @prakhartandon_org/logm

Usage

import LogMonitor from "@prakhartandon_org/logm"

// initialize the log monitor
const Logger = new LogMonitor("dev") // pass "prod" for production, default is "dev"
Logger.log("Hello from my package")
Logger.warn("Hello from my package")
Logger.info("Hello from my package")
Logger.error("Hello from my package")

//=> 'hello from my package'

Log Styling

  • Contains some default styling for the logs, based on the type.

Helper Functions

  • flush - To clear the logs batch (dev mode) and send the logs to the server (prod mode).
  • getBatchSize - To get the batch size for the logs.
  • getBatch - To get the batch of logs.
  • setIdLogM: To set the id for the logM instance. (maybe send userID here, that'll help in searching logs for a particular user.)

Log Location (Line Number) Script

This package also comes with a script that can be used to log the line number of the log statement. This uses fs and path modules to read the file & append the line number to the log, warn, info & error statements.

# Run script:
node ./node_modules/@prakhartandon_org/logm/lib/setLineNumScript.js <paths>
  • <paths>: Paths to the directories where you want to append the line number to the log statements.
  • Example: node ./node_modules/@prakhartandon_org/logm/lib/setLineNumScript.js ./ui ./plugin

Logs after running the script

Logger.log("[ @Location: index.ts:1 ]", "Hello from my package")
Logger.warn("[ @Location: index.ts:1 ]", "Hello from my package")
Logger.info("[ @Location: index.ts:1 ]", "Hello from my package")
Logger.error("[ @Location: index.ts:1 ]", "Hello from my package")

Production Mode

  • In production mode, the logs are not displayed in the console.
  • The logs will be sent to the server of your choice.
  • You can set the POST Endpoint & API Token in the LogMonitor constructor.
const Logger = new LogMonitor("prod", "https://your-endpoint.com", "Bearer <your-api-token>")

Contributing

Feel free to submit a pull request if you find any bugs or want to add new features.