Add option to log every request start and end to loggly (#15243)

This commit is contained in:
Phillip Thelen
2024-06-14 15:51:10 +02:00
committed by GitHub
parent dde675fdc1
commit 4da53f83c9
5 changed files with 86 additions and 0 deletions

View File

@@ -59,7 +59,17 @@ export function generateReq (options = {}) {
header (header) {
return this.headers[header];
},
listeners: {},
session: {},
on (key, func) {
if (!this.listeners[key]) {
this.listeners[key] = [];
}
this.listeners[key].push(func);
},
end () {
this.listeners.close.forEach(func => func());
},
};
const req = defaultsDeep(options, defaultReq);