Socket
Socket
Sign inDemoInstall

debug-threads-ns

Package Overview
Dependencies
23
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    debug-threads-ns

Debug namespace structure helper coupled with thread-context


Version published
Maintainers
1
Created

Readme

Source

NPM Build Status npm version npm

debug-threads-ns

This module is located at https://github.com/Aggtaa/debug-threads-ns. Any other location is either a fork or a copy.

Overview

This module is a simple helper for debug namespaces, especially useful for typescript projects.

You can provide static namespace structure or embed thread-context dynamic namespace identifying current "thread".

Usage

Its this simple:

import { debug, setup, ExtendedDebugger, threadContext } from "debug-threads-ns";
import express from 'express';

setup('myAppName');

export interface Debugger extends ExtendedDebugger {
    db: ExtendedDebugger;
    web: ExtendedDebugger & {
        thread: ExtendedDebugger;
    };
}

debug.warn('Process started');
// renders line "myappaname Process started"

const app = new express.Express();
debug.web.info('Express app created');
// renders line "myappaname:web Express app created"
app.use((req, res, next) => {
    threadContext.init();
    debug.web.thread.debug(req.method + ' ' + req.originalPath);
    // renders line "myappaname:web:$h4JJd20L GET /"
});

Keywords

FAQs

Last updated on 27 Sep 2023

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc