Added debug logging

This commit is contained in:
MrFry 2020-03-12 22:25:26 +01:00
parent 72aefca297
commit a7a75bd9d4
4 changed files with 62 additions and 6 deletions

View file

@ -273,6 +273,8 @@ app.post('/isAdding', function (req, res) {
logger.LogReq(req)
// automatically saves to dataFile every n write
logger.DebugLog('request.body:', 4)
logger.DebugLog(req.body, 4)
let result = actions.ProcessIncomingRequest(
req.body.datatoadd,
data,
@ -299,6 +301,7 @@ app.get('/ask', function (req, res) {
let subj = req.query.subj || ''
let question
try {
logger.DebugLog('Decoding URI component', 4)
question = decodeURIComponent(req.query.q)
} catch (e) {
console.err(req.query)
@ -306,11 +309,16 @@ app.get('/ask', function (req, res) {
}
let recData = {}
try {
logger.DebugLog('Parsing req.query.data', 4)
recData = JSON.parse(req.query.data)
} catch (e) {
logger.Log(`Unable to parse recieved question data! '${req.query.data}'`, logger.GetColor('redbg'))
}
logger.DebugLog('Searching in DB', 4)
let r = data.Search(question, subj, recData)
logger.DebugLog('Result length: ' + r.length, 1)
logger.DebugLog('Result:', 3)
logger.DebugLog(r, 3)
res.json({
result: r,