diff --git a/pom.xml b/pom.xml index ea2becc5..0d880cd1 100644 --- a/pom.xml +++ b/pom.xml @@ -27,7 +27,7 @@ 4.12.0 5.6.0 2.17.2 - 4.0.10 + 4.0.11 2.0.7 2.0.8 2.1.0 diff --git a/src/main/java/org/entur/lamassu/leader/FeedUpdater.java b/src/main/java/org/entur/lamassu/leader/FeedUpdater.java index 562b98ff..d40f7005 100644 --- a/src/main/java/org/entur/lamassu/leader/FeedUpdater.java +++ b/src/main/java/org/entur/lamassu/leader/FeedUpdater.java @@ -136,6 +136,8 @@ private void createSubscription(FeedProvider feedProvider) { enableValidation ); + var interceptor = new LoggingSubscriptionUpdateInterceptor(feedProvider); + String id; if (feedProvider.getVersion() != null && feedProvider.getVersion().startsWith("3")) { @@ -150,7 +152,8 @@ private void createSubscription(FeedProvider feedProvider) { ); receiveV3Update(feedProvider, gbfsV3Delivery); cacheReady.set(true); - } + }, + interceptor ); } else { id = @@ -164,7 +167,8 @@ private void createSubscription(FeedProvider feedProvider) { GbfsFeedVersionMappers.map(gbfsV2Delivery, feedProvider.getLanguage()) ); cacheReady.set(true); - } + }, + interceptor ); } diff --git a/src/main/java/org/entur/lamassu/leader/LoggingSubscriptionUpdateInterceptor.java b/src/main/java/org/entur/lamassu/leader/LoggingSubscriptionUpdateInterceptor.java new file mode 100644 index 00000000..371f1499 --- /dev/null +++ b/src/main/java/org/entur/lamassu/leader/LoggingSubscriptionUpdateInterceptor.java @@ -0,0 +1,42 @@ +/* + * + * + * * Licensed under the EUPL, Version 1.2 or – as soon they will be approved by + * * the European Commission - subsequent versions of the EUPL (the "Licence"); + * * You may not use this work except in compliance with the Licence. + * * You may obtain a copy of the Licence at: + * * + * * https://joinup.ec.europa.eu/software/page/eupl + * * + * * Unless required by applicable law or agreed to in writing, software + * * distributed under the Licence is distributed on an "AS IS" basis, + * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * * See the Licence for the specific language governing permissions and + * * limitations under the Licence. + * + */ + +package org.entur.lamassu.leader; + +import org.entur.gbfs.SubscriptionUpdateInterceptor; +import org.entur.lamassu.model.provider.FeedProvider; +import org.slf4j.MDC; + +public class LoggingSubscriptionUpdateInterceptor implements SubscriptionUpdateInterceptor { + private final FeedProvider feedProvider; + + public LoggingSubscriptionUpdateInterceptor( + FeedProvider feedProvider + ) { + this.feedProvider = feedProvider; + } + @Override + public void beforeUpdate() { + MDC.put("systemId", feedProvider.getSystemId()); + } + + @Override + public void afterUpdate() { + MDC.remove("systemId"); + } +} diff --git a/src/main/resources/logback.xml b/src/main/resources/logback.xml index a6ce822a..e4886b74 100644 --- a/src/main/resources/logback.xml +++ b/src/main/resources/logback.xml @@ -30,6 +30,9 @@ "serviceContext": { "service": "lamassu" }, + "mdc": { + "systemId": "%X{systemId}" + }, "message": "%message\n%ex{full}", "severity": "%level", "reportLocation": {