I am trying to write state info logs in a code block that uses express
, unirest
and async
modules as shown below.
const fsTest = require("fs");
app.post(someURL, function (req, res) {
fsTest.appendFile("c:/fs.txt","\r\nInOf")
async.series({
one: function (callback) {
fsTest.appendFile("c:/fs.txt","\r\nInOf2")
someOperation();
fsTest.appendFile("c:/fs.txt","\r\nInOf3")
callback(false,"");
},
//form search query
two: function (callback) {
fsTest.appendFile("c:/fs.txt","\r\nInOf4")
anotherOperation();
urClient.post("https://" + server + url)
.header('Content-Type', 'application/json')
.send(qrySearchJSON)
.end(
function (response) {
});
}
}, function (err,oResp) {
errHandler();
});
});
But my logs always appear out of sequence as shown below:
InOf2
InOf4
InOf3
InOf
InOf
InOf2
InOf3
InOf4
InOf
InOf2
InOf4
InOf3
InOf2
InOf
InOf4
InOf3
InOf
InOf2
InOf3
InOf4
What could possibly be the reason and what approach should i take to fix it.
via StillNestling
No comments:
Post a Comment