Skip to content
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

#600 Requests without request body are not logged by optimzed logger fix #656

Merged
merged 2 commits into from
Apr 24, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

import java.io.IOException;
import java.io.OutputStream;
import java.nio.charset.StandardCharsets;
import java.time.OffsetDateTime;

import jakarta.inject.Inject;
import jakarta.inject.Named;
Expand Down Expand Up @@ -111,6 +111,10 @@ protected void processRequest(ContainerRequestContext requestContext) {
appendRequestLine(logMessage, requestContext);
appendRequestHeaders(logMessage, requestContext);

if (!requestContext.hasEntity() || requestContext.getLength() <= 0) {
log.info(logMessage.toString());
}

int maxRequestEntityLogSize = requestResponseLogger.getMaxRequestEntityLogSize(requestContext);

var requestLoggerInputStream = new RequestLoggerInputStream(
Expand Down Expand Up @@ -202,6 +206,8 @@ protected void appendRequestHeaders(StringBuilder b, ContainerRequestContext req
*/
protected void appendRequestLine(StringBuilder b, ContainerRequestContext requestContext) {
b.append(requestResponseLogger.printRequestLine(requestContext));
// Mivel csak a stream végén történik a logolás, a timestamp nem a request beérkezését mutatja
b.append(RequestResponseLogger.REQUEST_PREFIX).append("-- Request timestamp:").append(OffsetDateTime.now()).append('\n');
speter555 marked this conversation as resolved.
Show resolved Hide resolved
}

/**
Expand Down
4 changes: 3 additions & 1 deletion docs/en/migration/migration260to270.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,11 @@ which can throw `hu.icellmobilsoft.coffee.se.api.exception.BaseException`.

=== coffee-rest

* Tha classes found in the `hu.icellmobilsoft.coffee.rest.exception` package use the new `hu.icellmobilsoft.coffee.se.api.exception.BaseException`.
* The classes found in the `hu.icellmobilsoft.coffee.rest.exception` package use the new `hu.icellmobilsoft.coffee.se.api.exception.BaseException`.
Such as `DefaultBaseExceptionMapper`, `DefaultExceptionMessageTranslator`, `DefaultGeneralExceptionMapper` and `IExceptionMessageTranslator`.

* The `hu.icellmobilsoft.coffee.rest.log.optimized.BaseRestLogger` has been improved so the HTTP GET calls are logged now.

==== Migration

* `jakarta.ws.rs.ext.ExceptionMapper` and `hu.icellmobilsoft.coffee.rest.exception.IExceptionMessageTranslator`
Expand Down
2 changes: 2 additions & 0 deletions docs/hu/migration/migration260to270.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ fgv-t vár, amik dobhatnak `hu.icellmobilsoft.coffee.se.api.exception.BaseExcept
`DefaultExceptionMessageTranslator`, `DefaultGeneralExceptionMapper` és `IExceptionMessageTranslator` osztályok már
az új `hu.icellmobilsoft.coffee.se.api.exception.BaseException`-el dolgoznak.

* `hu.icellmobilsoft.coffee.rest.log.optimized.BaseRestLogger` javításra került, a HTTP GET kérések is már logolódnak.

==== Átállás

* A `jakarta.ws.rs.ext.ExceptionMapper` és `hu.icellmobilsoft.coffee.rest.exception.IExceptionMessageTranslator`
Expand Down
Loading