11package com .uid2 .operator .vertx ;
22
3+ import com .uid2 .shared .auth .IAuthorizable ;
4+ import com .uid2 .shared .auth .OperatorKey ;
5+ import com .uid2 .shared .middleware .AuthMiddleware ;
36import io .vertx .core .Handler ;
47import io .vertx .core .http .HttpClosedException ;
58import io .vertx .core .http .HttpServerResponse ;
@@ -19,16 +22,23 @@ public void handle(RoutingContext ctx) {
1922 String url = ctx .normalizedPath ();
2023 Throwable t = ctx .failure ();
2124
25+ final IAuthorizable profile = AuthMiddleware .getAuthClient (ctx );
26+ final OperatorKey operatorKey = profile instanceof OperatorKey ? (OperatorKey ) profile : null ;
27+ String participant = "unknown" ;
28+ if (operatorKey != null ) {
29+ participant = operatorKey .getName ();
30+ }
31+
2232 if (t != null ) {
2333 // Because Vert.x swallows stack traces so cannot log stack trace
2434 // And we want to ignore HttpClosedException errors as it is (usually) caused by users and no impact
2535 if (t instanceof HttpClosedException ) {
26- LOGGER .warn ("Ignoring exception - URL: [{}] - Error:" , url , t );
36+ LOGGER .warn ("Ignoring exception - URL: [{}], Participant: [{}] - Error:" , url , participant , t );
2737 response .end ();
2838 } else if (statusCode >= 500 && statusCode < 600 ) { // 5xx is server error, so error
29- LOGGER .error ("URL: [{}] - Error response code: [{}] - Error:" , url , statusCode , t );
39+ LOGGER .error ("URL: [{}], Participant: [{}] - Error response code: [{}] - Error:" , url , participant , statusCode , t );
3040 } else if (statusCode >= 400 && statusCode < 500 ) { // 4xx is user error, so just warn
31- LOGGER .warn ("URL: [{}] - Error response code: [{}] - Error:" , url , statusCode , t );
41+ LOGGER .warn ("URL: [{}], Participant: [{}] - Error response code: [{}] - Error:" , url , participant , statusCode , t );
3242 }
3343 }
3444
0 commit comments