Search in sources :

Example 1 with ResponseLogMessage

use of com.dtflys.forest.logging.ResponseLogMessage in project forest by dromara.

the class SyncHttpclientRequestSender method logResponse.

public void logResponse(ForestResponse response) {
    LogConfiguration logConfiguration = request.getLogConfiguration();
    if (!logConfiguration.isLogEnabled() || response.isLogged()) {
        return;
    }
    response.setLogged(true);
    ResponseLogMessage logMessage = new ResponseLogMessage(response, response.getStatusCode());
    ForestLogHandler logHandler = logConfiguration.getLogHandler();
    if (logHandler != null) {
        if (logConfiguration.isLogResponseStatus()) {
            logHandler.logResponseStatus(logMessage);
        }
        if (logConfiguration.isLogResponseContent()) {
            logHandler.logResponseContent(logMessage);
        }
    }
}
Also used : ForestLogHandler(com.dtflys.forest.logging.ForestLogHandler) LogConfiguration(com.dtflys.forest.logging.LogConfiguration) ResponseLogMessage(com.dtflys.forest.logging.ResponseLogMessage)

Example 2 with ResponseLogMessage

use of com.dtflys.forest.logging.ResponseLogMessage in project forest by dromara.

the class OkHttp3Executor method logResponse.

public void logResponse(ForestResponse response) {
    LogConfiguration logConfiguration = request.getLogConfiguration();
    if (!logConfiguration.isLogEnabled() || response.isLogged()) {
        return;
    }
    response.setLogged(true);
    ResponseLogMessage logMessage = new ResponseLogMessage(response, response.getStatusCode());
    ForestLogHandler logHandler = logConfiguration.getLogHandler();
    if (logHandler != null) {
        if (logConfiguration.isLogResponseStatus()) {
            logHandler.logResponseStatus(logMessage);
        }
        if (logConfiguration.isLogResponseContent()) {
            logHandler.logResponseContent(logMessage);
        }
    }
}
Also used : ForestLogHandler(com.dtflys.forest.logging.ForestLogHandler) LogConfiguration(com.dtflys.forest.logging.LogConfiguration) ResponseLogMessage(com.dtflys.forest.logging.ResponseLogMessage)

Aggregations

ForestLogHandler (com.dtflys.forest.logging.ForestLogHandler)2 LogConfiguration (com.dtflys.forest.logging.LogConfiguration)2 ResponseLogMessage (com.dtflys.forest.logging.ResponseLogMessage)2