debug-threads-ns
v0.2.3
Published
Debug namespace structure helper coupled with thread-context
Downloads
333
Maintainers
Readme
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 /"
});