Node.js Application Debug Logs

JS
S
JavaScript

Using industry standard modules is an approach that I always recommend against creating your own implementation. To use the debug package: `DEBUG=app* NODE_ENV=staging npm run watch`

1/*
2   NPM Package Installation:
3  `npm install debug --save`
4  `npm install @types/debug --save`
5*/
6import * as Debug from 'debug';
7
8const debug = Debug('app:boot');
9debug(`Loading environment variables ${process.env.NODE_ENV}`);
10
11// ...
12
13import * as Debug from 'debug';
14
15const debug = Debug('app:service:loader');
16debug(`Loading assets`);
17
18/*
19  Troubleshooting TS
20  import debug from 'debug';
21  (<any>window).debug = debug;
22*/

Created on 2/6/2019