debug-threads-ns
TypeScript icon, indicating that this package has built-in type declarations

0.2.3 • Public • Published

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 /"
});

Package Sidebar

Install

npm i debug-threads-ns

Weekly Downloads

22

Version

0.2.3

License

MIT

Unpacked Size

4.37 kB

Total Files

4

Last publish

Collaborators

  • aggtaa