summaryrefslogtreecommitdiffstats
path: root/cds-ui/server/src
diff options
context:
space:
mode:
authorDan Timoney <dtimoney@att.com>2019-07-08 13:38:11 +0000
committerGerrit Code Review <gerrit@onap.org>2019-07-08 13:38:11 +0000
commit45b1ed540e79376ab832a18d7765986ef884ff76 (patch)
tree7de8ae65153fc6d951c39e33e04b4fcd005e0ccf /cds-ui/server/src
parentf6dcf43ffee549b1db9ec2e09e4122b2b84c2364 (diff)
parent1035ca70c25e1e57f3d68aebbd9155648f53e3a4 (diff)
Merge "Enhance logger to the server"
Diffstat (limited to 'cds-ui/server/src')
-rw-r--r--cds-ui/server/src/sequence.ts13
1 files changed, 10 insertions, 3 deletions
diff --git a/cds-ui/server/src/sequence.ts b/cds-ui/server/src/sequence.ts
index b282cbc62..84da5249d 100644
--- a/cds-ui/server/src/sequence.ts
+++ b/cds-ui/server/src/sequence.ts
@@ -31,6 +31,7 @@ import {
SequenceHandler,
} from '@loopback/rest';
import { logger } from './logger/logger';
+import { v4 as uuid } from 'uuid';
const SequenceActions = RestBindings.SequenceActions;
@@ -44,16 +45,22 @@ export class MySequence implements SequenceHandler {
) { }
async handle(context: RequestContext) {
+ const { request, response } = context;
try {
- const { request, response } = context;
- logger.info("Incoming request from %s %s and with header %s query %s params %s",
- request.method, request.url, JSON.stringify(request.headers), JSON.stringify(request.query), JSON.stringify(request.params))
+ if (!('X-ONAP-RequestID' in request.headers || 'x-onap-requestid' in request.headers)) {
+ request.headers = { 'X-ONAP-RequestID': uuid(), ...request.headers}
+ logger.info(JSON.stringify(request.headers))
+ }
const route = this.findRoute(request);
const args = await this.parseParams(request, route);
const result = await this.invoke(route, args);
this.send(response, result);
} catch (err) {
this.reject(context, err);
+ } finally {
+ const { authorization, ...headers} = request.headers;
+ logger.info("Incoming request from %s %s and with header %s query %s params %s and response code: %s",
+ request.method, request.url, JSON.stringify(headers), JSON.stringify(request.query), JSON.stringify(request.params), JSON.stringify(response.statusCode))
}
}
}