improve error logging
This commit is contained in:
@@ -118,7 +118,7 @@ const eventController = {
|
||||
order: [[Resource, 'id', 'DESC']]
|
||||
})
|
||||
} catch (e) {
|
||||
log.error(e)
|
||||
log.error('[EVENT]', e)
|
||||
return res.sendStatus(400)
|
||||
}
|
||||
|
||||
@@ -194,7 +194,7 @@ const eventController = {
|
||||
const notifier = require('../../notifier')
|
||||
notifier.notifyEvent('Create', event.id)
|
||||
} catch (e) {
|
||||
log.error(e)
|
||||
log.error('[EVENT]', e)
|
||||
res.sendStatus(404)
|
||||
}
|
||||
},
|
||||
@@ -334,7 +334,7 @@ const eventController = {
|
||||
notifier.notifyEvent('Create', event.id)
|
||||
}
|
||||
} catch (e) {
|
||||
log.error(e)
|
||||
log.error('[EVENT ADD]', e)
|
||||
res.sendStatus(400)
|
||||
}
|
||||
},
|
||||
@@ -419,6 +419,7 @@ const eventController = {
|
||||
}
|
||||
const notifier = require('../../notifier')
|
||||
await notifier.notifyEvent('Delete', event.id)
|
||||
log.debug('[EVENT REMOVED]', event.title)
|
||||
await event.destroy()
|
||||
res.sendStatus(200)
|
||||
} else {
|
||||
@@ -474,7 +475,8 @@ const eventController = {
|
||||
{ model: Place, required: true, attributes: ['id', 'name', 'address'] }
|
||||
]
|
||||
}).catch(e => {
|
||||
log.error(e)
|
||||
log.error('[EVENT]', e)
|
||||
return []
|
||||
})
|
||||
|
||||
return events.map(e => {
|
||||
|
||||
@@ -42,7 +42,7 @@ const oauthController = {
|
||||
delete client.id
|
||||
res.json(client)
|
||||
} catch (e) {
|
||||
log.error(e)
|
||||
log.error('[OAUTH CLIENT]', e)
|
||||
res.status(400).json(e)
|
||||
}
|
||||
},
|
||||
|
||||
@@ -103,7 +103,7 @@ const settingsController = {
|
||||
settingsController[is_secret ? 'secretSettings' : 'settings'][key] = value
|
||||
return true
|
||||
} catch (e) {
|
||||
log.error(e)
|
||||
log.error('[SETTING SET]', e)
|
||||
return false
|
||||
}
|
||||
},
|
||||
@@ -129,7 +129,7 @@ const settingsController = {
|
||||
.png({ quality: 90 })
|
||||
.toFile(baseImgPath + '.png', async (err, info) => {
|
||||
if (err) {
|
||||
log.error(err)
|
||||
log.error('[LOGO]', err)
|
||||
}
|
||||
const image = await readFile(baseImgPath + '.png')
|
||||
const favicon = await toIco([image], { sizes: [64], resize: true })
|
||||
|
||||
@@ -103,7 +103,7 @@ const userController = {
|
||||
mail.send(config.admin_email, 'admin_register', { user, config })
|
||||
res.sendStatus(200)
|
||||
} catch (e) {
|
||||
log.error('Registration error: "%s"', e)
|
||||
log.error('Registration error:', e)
|
||||
res.status(404).json(e)
|
||||
}
|
||||
},
|
||||
@@ -116,7 +116,7 @@ const userController = {
|
||||
mail.send(user.email, 'user_confirm', { user, config }, req.settings.locale)
|
||||
res.json(user)
|
||||
} catch (e) {
|
||||
log.error('User creation error: %s', e)
|
||||
log.error('User creation error:', e)
|
||||
res.status(404).json(e)
|
||||
}
|
||||
},
|
||||
@@ -127,7 +127,7 @@ const userController = {
|
||||
user.destroy()
|
||||
res.sendStatus(200)
|
||||
} catch (e) {
|
||||
log.error('User removal error: "%s"', e)
|
||||
log.error('User removal error:"', e)
|
||||
res.status(404).json(e)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -145,7 +145,7 @@ api.use((req, res) => res.sendStatus(404))
|
||||
|
||||
// Handle 500
|
||||
api.use((error, req, res, next) => {
|
||||
log.error(error)
|
||||
log.error('[API ERROR]', error)
|
||||
res.status(500).send('500: Internal Server Error')
|
||||
})
|
||||
|
||||
|
||||
@@ -61,7 +61,7 @@ const mail = {
|
||||
}
|
||||
return email.send(msg)
|
||||
.catch(e => {
|
||||
log.error('Error sending email => %s', e)
|
||||
log.error('[MAIL]', e)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ oauth.use((req, res) => res.sendStatus(404))
|
||||
|
||||
oauth.use((err, req, res, next) => {
|
||||
const error_msg = err.toString()
|
||||
log.error(error_msg)
|
||||
log.error('[OAUTH USE]', error_msg)
|
||||
res.status(500).send(error_msg)
|
||||
})
|
||||
|
||||
|
||||
@@ -8,9 +8,7 @@ const config = require('config')
|
||||
|
||||
try {
|
||||
mkdirp.sync(config.upload_path + '/thumb')
|
||||
} catch (e) {
|
||||
log.error(e)
|
||||
}
|
||||
} catch (e) {}
|
||||
|
||||
const DiskStorage = {
|
||||
_handleFile (req, file, cb) {
|
||||
@@ -25,11 +23,11 @@ const DiskStorage = {
|
||||
let onError = false
|
||||
const err = e => {
|
||||
if (onError) {
|
||||
log.error(err)
|
||||
log.error('[UPLOAD]', err)
|
||||
return
|
||||
}
|
||||
onError = true
|
||||
log.error(e)
|
||||
log.error('[UPLOAD]', e)
|
||||
req.err = e
|
||||
cb(null)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user