-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
To enable it in component add following in properties: logging.level.eu.h2020.symbiote.security.communication=DEBUG
- Loading branch information
1 parent
ca724f0
commit 974115d
Showing
2 changed files
with
45 additions
and
1 deletion.
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
39 changes: 39 additions & 0 deletions
39
src/main/java/eu/h2020/symbiote/security/communication/ApacheCommonsLogger4Feign.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,39 @@ | ||
package eu.h2020.symbiote.security.communication; | ||
|
||
import java.io.IOException; | ||
|
||
import org.apache.commons.logging.Log; | ||
|
||
import feign.Request; | ||
import feign.Response; | ||
|
||
public class ApacheCommonsLogger4Feign extends feign.Logger { | ||
private Log logger; | ||
|
||
public ApacheCommonsLogger4Feign(Log logger) { | ||
this.logger = logger; | ||
} | ||
|
||
@Override | ||
protected void logRequest(String configKey, Level logLevel, Request request) { | ||
if (logger.isDebugEnabled()) { | ||
super.logRequest(configKey, logLevel, request); | ||
} | ||
} | ||
|
||
@Override | ||
protected Response logAndRebufferResponse(String configKey, Level logLevel, Response response, | ||
long elapsedTime) throws IOException { | ||
if (logger.isDebugEnabled()) { | ||
return super.logAndRebufferResponse(configKey, logLevel, response, elapsedTime); | ||
} | ||
return response; | ||
} | ||
|
||
@Override | ||
protected void log(String configKey, String format, Object... args) { | ||
if (logger.isDebugEnabled()) { | ||
logger.debug(String.format(methodTag(configKey) + format, args)); | ||
} | ||
} | ||
} |