A wrapper around the debug module, providing the additional ability to determine the calling file name for debug's namespace. Get automatic unique namespaces each time you use debug!
npm i debug-filename
Namespace prefix, Default value is app
.
The directory hierarchy at the beginning of the namespace, Default value is 0
.
The number of directory hierarchies the namespace contains, Default value is 0
.
// test/foo.js
import debug from 'debug-filename';
// DEBUG can be triggered by the following format:
// - DEBUG=app:test:foo
// - DEBUG=app:test:*
// - DEBUG=app:*
// - DEBUG=*
debug('logging data'); // "app:test:foo logging data"
-
Modify App name
// test/foo.js import debug from 'debug-filename'; // DEBUG_FILENAME_PREFIX=Application DEBUG=Application:test:foo debug('logging data'); // "Application:test:foo logging data"
-
Stripped off the first layer of the catalog
// test/foo.js import debug from 'debug-filename'; // DEBUG_FILENAME_START=1 DEBUG=app:foo debug('logging data'); // "app:foo logging data"
-
Specify the length of the namespace
// test/a/b/c/d.js import debug from 'debug-filename'; // DEBUG_FILENAME_LENGTH=2 DEBUG=app:test:a debug('logging data'); // "app:test:a logging data"