feat: better upload.onHold debugging messages

expose util.inspect via utils when on dev mode
This commit is contained in:
Bobby 2022-09-24 06:33:58 +07:00
parent 32efacd411
commit c47d3f5437
No known key found for this signature in database
GPG Key ID: 941839794CBF5A09
2 changed files with 13 additions and 2 deletions

View File

@ -187,6 +187,10 @@ self.getUniqueUploadIdentifier = async (length, extension = '', res) => {
continue
}
if (utils.devmode) {
logger.debug(`upload.onHold: ${utils.inspect(self.onHold)}`)
}
// Unhold identifier once the Response has been sent
if (res) {
if (!res.locals.identifiers) {
@ -220,7 +224,10 @@ self.unholdUploadIdentifiers = res => {
for (const identifier of res.locals.identifiers) {
self.onHold.delete(identifier)
logger.debug(`Unheld identifier ${identifier}.`)
if (utils.devmode) {
logger.debug(`upload.onHold: ${utils.inspect(self.onHold)} -> ${utils.inspect(identifier)}`)
}
}
delete res.locals.identifiers

View File

@ -16,8 +16,12 @@ const SimpleDataStore = require('./utils/SimpleDataStore')
const config = require('./../config')
const logger = require('./../logger')
const devmode = process.env.NODE_ENV === 'development'
const self = {
devmode: process.env.NODE_ENV === 'development',
devmode,
inspect: devmode && require('util').inspect,
db: knex(config.database),
conf: {
// Allow some config options to be overriden via env vars