Hello, I was looking to have multiple logs, the standard process.stdout, a fileStreamRotate and a mongo variant. I was looking to see if there would be any issues with a few being synchronous and a few being asynchronous. I didn't see much in the way of problems except the fact that the _startTime is set to undefined each time. Which could cause problems between multiple morgan instances.
I understand what I am about to write is an exaggeration and prob not recommended anyway, but I just wanted to point it out.
var morgan = require("morgan");
var app = require("express")();
var stream1 = require("fs").createWriteStream("log.log");
var stream2 = process.stdout;
app.use(morgan("dev", { stream: stream1 }));
app.use((req, res, next) => { setTimeout(next, 2000); }); // Wait 2 seconds
app.use(morgan("dev", { stream: stream2 }));
app.use((req, res) => { res.send(); });
app.listen(3000);
As I said, this would be an extremely strange behaviour, but it does point out that both morgans record that the response time is ~8ms rather than over 2008ms
Hello, I was looking to have multiple logs, the standard
process.stdout, afileStreamRotateand amongovariant. I was looking to see if there would be any issues with a few being synchronous and a few being asynchronous. I didn't see much in the way of problems except the fact that the _startTime is set to undefined each time. Which could cause problems between multiple morgan instances.I understand what I am about to write is an exaggeration and prob not recommended anyway, but I just wanted to point it out.
As I said, this would be an extremely strange behaviour, but it does point out that both morgans record that the response time is ~8ms rather than over 2008ms