-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add subscription update interceptor to add systemId to update logs
- Loading branch information
Showing
4 changed files
with
52 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
src/main/java/org/entur/lamassu/leader/LoggingSubscriptionUpdateInterceptor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters