summaryrefslogtreecommitdiffstats
path: root/cds-ui/server/src
diff options
context:
space:
mode:
authorRami <rmohamed.ext@orange.com>2019-06-23 15:13:04 +0200
committerRami <rmohamed.ext@orange.com>2019-06-23 15:13:04 +0200
commit1035ca70c25e1e57f3d68aebbd9155648f53e3a4 (patch)
treee84c063eedba24a813a04f7c4c9e4cbabb4304de /cds-ui/server/src
parentda79303b367ed5d4f12a279a401dee379f38147e (diff)
Enhance logger to the server
- Remove autorization from request logs - add request ID if it doesn't exist - log response code Issue-ID: CCSDK-1295 Change-Id: Ia83125bd85ddb1cd89f02cf55220f1aa11049810 Signed-off-by: Rami <rmohamed.ext@orange.com>
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))
}
}
}