-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5a8db22
commit e2b214f
Showing
3 changed files
with
107 additions
and
0 deletions.
There are no files selected for viewing
60 changes: 60 additions & 0 deletions
60
...-ddd-application/src/main/java/com/taotao/cloud/ddd/application/config/LogbookConfig.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,60 @@ | ||
package com.taotao.cloud.ddd.application.config; | ||
|
||
import java.io.IOException; | ||
import org.springframework.context.annotation.Bean; | ||
import org.zalando.logbook.Correlation; | ||
import org.zalando.logbook.HttpRequest; | ||
import org.zalando.logbook.HttpResponse; | ||
import org.zalando.logbook.Logbook; | ||
import org.zalando.logbook.Precorrelation; | ||
import org.zalando.logbook.Sink; | ||
import org.zalando.logbook.core.Conditions; | ||
import org.zalando.logbook.core.DefaultHttpLogFormatter; | ||
import org.zalando.logbook.core.DefaultHttpLogWriter; | ||
import org.zalando.logbook.core.DefaultSink; | ||
|
||
public class LogbookConfig { | ||
|
||
@Bean | ||
public Logbook logbook() { | ||
return Logbook.builder() | ||
.condition(Conditions.exclude(Conditions.requestTo("/users/*"), | ||
Conditions.contentType("application/json"))) | ||
.sink(new DefaultSink(new DefaultHttpLogFormatter(), new DefaultHttpLogWriter())) | ||
.sink(new Sink() { | ||
@Override | ||
public boolean isActive() { | ||
return Sink.super.isActive(); | ||
} | ||
|
||
@Override | ||
public void write(Precorrelation precorrelation, HttpRequest request) | ||
throws IOException { | ||
|
||
} | ||
|
||
@Override | ||
public void write(Correlation correlation, HttpRequest request, | ||
HttpResponse response) | ||
throws IOException { | ||
|
||
} | ||
|
||
@Override | ||
public void writeBoth(Correlation correlation, HttpRequest request, | ||
HttpResponse response) | ||
throws IOException { | ||
System.err.println("=============================="); | ||
System.err.println("request header:\t" + request.getHeaders()); | ||
System.err.println("request body:\t" + request.getBodyAsString()); | ||
System.out.println(); | ||
System.err.println("response header:\t" + response.getHeaders()); | ||
System.err.println("response body:\t" + response.getBodyAsString()); | ||
System.err.println("=============================="); | ||
} | ||
}) | ||
.build(); | ||
} | ||
|
||
; | ||
} |
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