Skip to content

Commit

Permalink
xx
Browse files Browse the repository at this point in the history
  • Loading branch information
shuigedeng committed Sep 5, 2024
1 parent 5a8db22 commit e2b214f
Show file tree
Hide file tree
Showing 3 changed files with 107 additions and 0 deletions.
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();
}

;
}
39 changes: 39 additions & 0 deletions taotao-cloud-ddd-assembly/src/main/resources/application-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1275,6 +1275,7 @@ taotao:
group: ${spring.application.name}
version: ${ttcVersion}
title: 系统管理模块
packages-to-scan: com.taotao.cloud.ddd.facade.controller.*
metrics:
enabled: true
druid:
Expand Down Expand Up @@ -1533,6 +1534,7 @@ logging:
#org.springframework.security.oauth2: off
#org.springframework.boot.autoconfigure: off
#org.elasticsearch.client: debug
org.zalando.logbook.Logbook: TRACE

test:
baseUrl: https://www.baidu.com
Expand Down Expand Up @@ -1744,3 +1746,40 @@ herodotus:
validate: local
jwk:
certificate: standard


logbook:
predicate:
include:
- path: /api/**
methods:
- GET
- POST
- path: /actuator/**
exclude:
- path: /actuator/health
- path: /api/admin/**
methods:
- POST
filter.enabled: true
secure-filter:
enabled: true
format:
style: http
strategy: body-only-if-status-at-least
minimum-status: 400
obfuscate:
headers:
- Authorization
- X-Secret
parameters:
- access_token
- password
write:
chunk-size: 1000
attribute-extractors:
- type: JwtFirstMatchingClaimExtractor
claim-names: [ "sub", "subject" ]
claim-key: Principal
- type: JwtAllMatchingClaimsExtractor
claim-names: [ "sub", "iat" ]
8 changes: 8 additions & 0 deletions taotao-cloud-ddd-domain/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,14 @@ dependencies {

api 'com.github.oshi:oshi-core:6.6.2'

api 'org.zalando:logbook-spring-boot-starter:3.9.0'
api 'org.zalando:logbook-httpclient5:3.9.0'
api 'org.zalando:logbook-netty:3.9.0'
api 'org.zalando:logbook-okhttp:3.9.0'
api 'org.zalando:logbook-okhttp2:3.9.0'
api 'org.zalando:logbook-openfeign:3.9.0'
api 'org.zalando:logbook-spring-webflux:3.9.0'

//api "io.github.shuigedeng:taotao-cloud-starter-apt")
//annotationProcessor "io.github.shuigedeng:taotao-cloud-starter-apt")

Expand Down

0 comments on commit e2b214f

Please sign in to comment.