diff --git a/utilities/debugBuilder.js b/utilities/debugBuilder.js index cd24590..65be4d9 100644 --- a/utilities/debugBuilder.js +++ b/utilities/debugBuilder.js @@ -1,5 +1,7 @@ // Debug const debug = require('debug'); +// Read .env file to process.env +require('dotenv').config(); /** * Create the different logging methods for a function @@ -13,6 +15,10 @@ exports.DebugBuilder = class DebugBuilder { this.DEBUG = debug(`${appName}:${fileName}:DEBUG`); this.VERBOSE = debug(`${appName}:${fileName}:VERBOSE`); 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(); + } } } \ No newline at end of file