Update debug to add a key, when set exit the app on error
.env key "EXIT_ON_ERROR"
This commit is contained in:
@@ -1,5 +1,7 @@
|
|||||||
// Debug
|
// Debug
|
||||||
const debug = require('debug');
|
const debug = require('debug');
|
||||||
|
// Read .env file to process.env
|
||||||
|
require('dotenv').config();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create the different logging methods for a function
|
* Create the different logging methods for a function
|
||||||
@@ -13,6 +15,10 @@ exports.DebugBuilder = class DebugBuilder {
|
|||||||
this.DEBUG = debug(`${appName}:${fileName}:DEBUG`);
|
this.DEBUG = debug(`${appName}:${fileName}:DEBUG`);
|
||||||
this.VERBOSE = debug(`${appName}:${fileName}:VERBOSE`);
|
this.VERBOSE = debug(`${appName}:${fileName}:VERBOSE`);
|
||||||
this.WARN = debug(`${appName}:${fileName}:WARNING`);
|
this.WARN = debug(`${appName}:${fileName}:WARNING`);
|
||||||
this.ERROR = debug(`${appName}:${fileName}:ERROR`).then(process.exit());
|
this.ERROR = (...messageParts) => {
|
||||||
|
const error = debug(`${appName}:${fileName}:ERROR`);
|
||||||
|
error(messageParts);
|
||||||
|
if (process.env.EXIT_ON_ERROR) process.exit();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user