Skip to content

UID2-4667 Log participant name #334

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>com.uid2</groupId>
<artifactId>uid2-core</artifactId>
<version>2.30.19</version>
<version>2.30.20-alpha-153-SNAPSHOT</version>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
Expand Down
14 changes: 12 additions & 2 deletions src/main/java/com/uid2/core/handler/GenericFailureHandler.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package com.uid2.core.handler;

import com.uid2.shared.auth.IAuthorizable;
import com.uid2.shared.auth.OperatorKey;
import com.uid2.shared.middleware.AuthMiddleware;
import io.vertx.core.Handler;
import io.vertx.core.http.HttpClosedException;
import io.vertx.core.http.HttpServerResponse;
Expand All @@ -19,11 +22,18 @@ public void handle(RoutingContext ctx) {
String url = ctx.normalizedPath();
Throwable t = ctx.failure();

final IAuthorizable profile = AuthMiddleware.getAuthClient(ctx);
final OperatorKey operatorKey = profile instanceof OperatorKey ? (OperatorKey) profile : null;
String participant = "unknown";
if (operatorKey != null) {
participant = operatorKey.getName();
}

if (t != null) {
if (statusCode >= 500 && statusCode < 600) { // 5xx is server error, so error
LOGGER.error("URL: [{}] - Error response code: [{}] - Error:", url, statusCode, t);
LOGGER.error("URL: [{}], Participant: [{}] - Error response code: [{}] - Error:", url, participant, statusCode, t);
} else if (statusCode >= 400 && statusCode < 500) { // 4xx is user error, so just warn
LOGGER.warn("URL: [{}] - Error response code: [{}] - Error:", url, statusCode, t);
LOGGER.warn("URL: [{}], Participant: [{}] - Error response code: [{}] - Error:", url, participant, statusCode, t);
}
}

Expand Down