pN
Size: a a a
pN
pN
C
N
ЧА
vt
N
N
N
ЧА
y
const http = require('http')
http.createServer((req, res) => {
a()
}).listen(3000)
function a() {
console.trace('')
}Trace
at a (/home/.../server.js:7:10)
at Server.<anonymous> (/home/.../server.js:3:2)
at Server.emit (node:events:376:20)
at parserOnIncoming (node:_http_server:907:12)
at HTTPParser.parserOnHeadersComplete (node:_http_common:126:17)
y
arguments.calleey
function a() {
try {
throw new Error()
} catch(err) {
console.log(err.stack)
}
}N
const http = require('http')
http.createServer((req, res) => {
a()
}).listen(3000)
function a() {
console.trace('')
}Trace
at a (/home/.../server.js:7:10)
at Server.<anonymous> (/home/.../server.js:3:2)
at Server.emit (node:events:376:20)
at parserOnIncoming (node:_http_server:907:12)
at HTTPParser.parserOnHeadersComplete (node:_http_common:126:17)
ЕВ
ЕВ
app.use((req, res, next) => {
const asyncLocalStorage = diContainer.get<any>(TYPES.AsyncLocalStorage);
asyncLocalStorage.run(new Map(), () => {
asyncLocalStorage.getStore().set("requestId", uuidv4());
next();
});
});log(...args): void {
const date = moment(new Date()).format("DD.MM.YY HH:mm:ss.SSS");
const store = this.asyncLocalStorage.getStore();
const logId = store ? store.get("requestId") : "context-is-lost";
console.log(date, logId, ...args);
}можно без di, просто через экспорт.R
SN
R
ЕВ