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

csb-inspector

v0.3.2

Published

Capture console.log and server errors and display it in a very useful real-time screen to be able to view the console.log of the server in the browser

Downloads

29

Readme

CSB-INSPECTOR

View complete Documentation

Introduction

Many times when developing an application with a Backend written in NodeJs, we tend to send many messages into the terminal “console.log (data)” to help us to keep track of the state of our application, at some point we find tedious to search that printing in the terminal, in some cases we are even mistaken in printing, in some cases we want to identify which file and line of code where that screen printing “console.log (data)” is running because NodeJs only prints the arguments that we pass and does not refer to which file and or in which line of code that print was executed.

csb-inspector is a library that identifies the file and code line where the “console.log (data)” screen printing is being executed and shows us the reference of where the printing is being executed.

If we see the previous image, we can see the reference to the file and line of code that print in the terminal belongs to.

Instalation

We go to our terminal and in the folder of our NodeJs project we install the dependency.

    $ npm install --save csb-inspector

Terminal

csb-inspector

In the main file of your nodejs application write this code

    const CsbInspector = require('csb-inspector');
    CsbInspector();

This is the simplest implementation, which helps to display the file and the line of code in the terminal.

Options

    const CsbInspector = require('csb-inspector');
    CsbInspector({
      outputs: [
        (path, key, args, date)=> {
          // path:  "reference to file",
          // key: "type of console, 'log', 'error'",
          // args: 'arguments',
          // date: 'Object Date, When execute console'
        }
      ]
    });

Description

Options | Description | Required | Default ------- | ----------- | -------- | ------- outputs | Array of functions that receive 4 parameters, which allows us to extend the functionality of the library | false | -

As we can see, we send you an object with an “outputs” property. It contains an array of functions that receive 4 parameters.

This property helps us to extend the functionality of this library, obtaining those parameters we could save them in a file or other options that we consider useful. This parameter is not required. This implementation will be useful for any NodeJs server.

Terminal and Express

csb-inspector/express-socket

The csb-inspector library provides a control panel that shows in the browser in real-time the prints in the terminal "console.log (data)" with its respective reference to the file and line of code and also displays the occurrence time. This functionality can be implemented for applications based on ExpressJs.

This code must be in the file where the server is initialized with ExpressJs.

  const express = require('express');
  const app = express();

  const CsbInspector = require('csb-inspector/express-socket');
  const options = {
      app: app
  }

  CsbInspector(options);

ServerPort - Is the port where the server is running

Open your browser and load 'http://localhost:{ServerPort}/_console'

Options

The library allows us to configure it according to our environment.

  const express = require('express');
  const app = express();

  const CsbInspector = require('csb-inspector/express-socket');
  const options = {
      app: app,
      route: "debugger_logs",
      port: 8888,
      host: "http://192.16.3.89",
      disabledBrowser: false,
      outputs: [
        (path, key, args, date)=> {
          // path:  "reference to file",
          // key: "type of console, 'log', 'error'",
          // args: 'arguments',
          // date: 'Object Date, when execute console'
            fs.appendFileSync("file.txt", path);
        }
      ]
    }
  CsbInspector(options);

Description

Options | Description | Required | Default ------- | ----------- | -------- | ------- app | Express application | true | - route | Route where the control panel will be displayed | false | _console host | Host of Server | false | 'http://localhost' port | Port through the socket listens | false | 8888 disabledBrowser | Disable control panel in browser | false | false outputs | Array of functions that receive 4 parameters, which allows us to extend the functionality of the library | false | -

Open your browser and load URL 'http://192.16.3.89:{ServerPort}/debugger_logs'.

URL - Built with the above parameters.

ServerPort - Is the port where the server is running.

We code

Browser

Terminal

Feedback

Find a bug or have a feature request? Please file an issue!

Contact

Follow @adrzelada

Adrian Pedro Zelada Torrez

Medium: @adrianpedrozeladatorrez.

Email: [email protected]