Compare commits

...

30 Commits

Author SHA1 Message Date
bvn13 36fa59c870 Revert "performance test"
This reverts commit 942df51f6d.
2022-08-16 15:09:04 +03:00
bvn13 4b1630456e Revert "small performance improvement"
This reverts commit 72fd298a43.
2022-08-16 15:09:01 +03:00
bvn13 72e5b9615c Revert "fix updating script"
This reverts commit 5034afd525.
2022-08-16 15:08:58 +03:00
bvn13 1446c40f04 Revert "fix maven"
This reverts commit 111f76c1e0.
2022-08-16 15:08:56 +03:00
bvn13 0d4a379837 Revert "gitignore"
This reverts commit 420a19c2be.
2022-08-16 15:08:48 +03:00
bvn13 420a19c2be gitignore 2022-08-16 14:39:10 +03:00
bvn13 27b4ad81e1 Merge pull request 'feature/performance-test' (#3) from feature/performance-test into develop
Reviewed-on: #3
2022-08-16 14:34:55 +03:00
bvn13 111f76c1e0 fix maven 2022-08-16 14:32:31 +03:00
bvn13 5034afd525 fix updating script 2022-08-16 14:30:53 +03:00
bvn13 72fd298a43 small performance improvement 2022-08-16 14:30:19 +03:00
bvn13 942df51f6d performance test 2022-08-14 01:19:01 +03:00
bvn13 9b32085279 fix 2022-08-01 14:23:07 +03:00
bvn13 d46d4c0cfb Update for next development version 2022-08-01 14:20:58 +03:00
bvn13 c833c3649b Merge tag '0.1.4' into develop
Tag release
2022-08-01 14:20:54 +03:00
bvn13 fca67c061b Merge branch 'release/0.1.4' 2022-08-01 14:20:54 +03:00
bvn13 ab50200939 Update versions for release 2022-08-01 14:20:48 +03:00
bvn13 4835a1ebd7 publishing script 2022-08-01 14:20:33 +03:00
bvn13 ec1b55ca31 changed level Debug to Info, refined the approach to specify logging level 2022-08-01 14:16:38 +03:00
bvn13 a1b6641c06 Update for next development version 2022-07-25 15:26:55 +03:00
bvn13 fc26734cd1 Merge branch 'release/0.1.3' 2022-07-25 15:26:53 +03:00
bvn13 bd1ba6c061 Merge tag '0.1.3' into develop
Tag release
2022-07-25 15:26:53 +03:00
bvn13 9aac4e4099 Update versions for release 2022-07-25 15:26:50 +03:00
bvn13 107070177f updated readme 2022-07-25 15:26:35 +03:00
bvn13 efaf166a07 Update for next development version 2022-07-25 14:54:38 +03:00
bvn13 e50e8f5164 Merge branch 'release/0.1.2' 2022-07-25 14:54:37 +03:00
bvn13 177def9285 Merge tag '0.1.2' into develop
Tag release
2022-07-25 14:54:37 +03:00
bvn13 cc3a25e783 Update versions for release 2022-07-25 14:54:34 +03:00
bvn13 2133247384 fixed readme 2022-07-25 14:54:20 +03:00
bvn13 52bb04f158 Update for next development version 2022-07-25 14:47:43 +03:00
bvn13 f6fab4c558 Merge tag '0.1.1' into develop
Tag release
2022-07-25 14:47:41 +03:00
4 changed files with 58 additions and 42 deletions

View File

@ -12,42 +12,40 @@ communication into one log entry.
## Old bad Logger
All parts are separeted from each other:
All parts are separated from each other:
1) Request:
1) request headers - every header is put into separated entry
2) requst body - at separated entry
2) request body - at separated entry
2) Response:
1) response headers - separately
2) response body - at separated entry as well
```
2022-07-25 14:12:43.572 DEBUG 1032530 --- [Executor] feign.Logger : [AuthApi#login] ---> POST https://example.com/api/v1/login HTTP/1.1
2022-07-25 14:12:43.573 DEBUG 1032530 --- [Executor] feign.Logger : [AuthApi#login] Content-Length: 23
2022-07-25 14:12:43.573 DEBUG 1032530 --- [Executor] feign.Logger : [AuthApi#login] Content-Type: application/json
2022-07-25 14:12:43.574 DEBUG 1032530 --- [Executor] feign.Logger : [AuthApi#login] user-agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4464.5 Safari/537.36
2022-07-25 14:12:43.575 DEBUG 1032530 --- [Executor] feign.Logger : [AuthApi#login]
2022-07-25 14:12:43.576 DEBUG 1032530 --- [Executor] feign.Logger : [AuthApi#login] {"login":"123456789"}
2022-07-25 14:12:43.576 DEBUG 1032530 --- [Executor] feign.Logger : [AuthApi#login] ---> END HTTP (21-byte body)
2022-07-25 14:12:43.901 DEBUG 1032530 --- [Executor] feign.Logger : [AuthApi#login] <--- UNKNOWN 200 (324ms)
2022-07-25 14:12:43.901 DEBUG 1032530 --- [Executor] feign.Logger : [AuthApi#login] cache-control: no-cache
2022-07-25 14:12:43.901 DEBUG 1032530 --- [Executor] feign.Logger : [AuthApi#login] cf-cache-status: DYNAMIC
2022-07-25 14:12:43.901 DEBUG 1032530 --- [Executor] feign.Logger : [AuthApi#login] cf-ray: 730476518ea441ce-AMS
2022-07-25 14:12:43.901 DEBUG 1032530 --- [Executor] feign.Logger : [AuthApi#login] content-type: application/json
2022-07-25 14:12:43.901 DEBUG 1032530 --- [Executor] feign.Logger : [AuthApi#login] date: Mon, 25 Jul 2022 11:12:43 GMT
2022-07-25 14:12:43.901 DEBUG 1032530 --- [Executor] feign.Logger : [AuthApi#login] expect-ct: max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"
2022-07-25 14:12:43.901 DEBUG 1032530 --- [Executor] feign.Logger : [AuthApi#login] feature-policy: accelerometer 'none'; camera 'none'; geolocation 'none'; gyroscope 'none'; magnetometer 'none'; microphone 'none'; payment *; usb 'none'
2022-07-25 14:12:43.901 DEBUG 1032530 --- [Executor] feign.Logger : [AuthApi#login] referrer-policy: strict-origin-when-cross-origin
2022-07-25 14:12:43.901 DEBUG 1032530 --- [Executor] feign.Logger : [AuthApi#login] server: cloudflare
2022-07-25 14:12:43.901 DEBUG 1032530 --- [Executor] feign.Logger : [AuthApi#login] set-cookie: ACCESS_TOKEN=eyJh9uygCUMA659bAZ54SHpSNy_KFXQ; Max-Age=1800; Domain=.example.com; Path=/; Secure; SameSite=None
2022-07-25 14:12:43.901 DEBUG 1032530 --- [Executor] feign.Logger : [AuthApi#login] strict-transport-security: max-age=31536000
2022-07-25 14:12:43.901 DEBUG 1032530 --- [Executor] feign.Logger : [AuthApi#login] x-content-type-options: nosniff
2022-07-25 14:12:43.901 DEBUG 1032530 --- [Executor] feign.Logger : [AuthApi#login] x-frame-options: sameorigin
2022-07-25 14:12:43.901 DEBUG 1032530 --- [Executor] feign.Logger : [AuthApi#login] x-xss-protection: 1; mode=block
2022-07-25 14:12:43.901 DEBUG 1032530 --- [Executor] feign.Logger : [AuthApi#login]
2022-07-25 14:12:43.902 DEBUG 1032530 --- [Executor] feign.Logger : [AuthApi#login] {"status":{"code":"OK","message":"OK"},"body":{"id":"20826"}}
2022-07-25 14:12:43.902 DEBUG 1032530 --- [Executor] feign.Logger : [AuthApi#login] <--- END HTTP (61-byte body)
2022-07-25 14:12:43.572 DEBUG 1032530 --- [Executor] feign.Logger : [AuthApi#login] ---> POST https://example.com/api/v1/login HTTP/1.1
2022-07-25 14:12:43.573 DEBUG 1032530 --- [Executor] feign.Logger : [AuthApi#login] Content-Length: 23
2022-07-25 14:12:43.573 DEBUG 1032530 --- [Executor] feign.Logger : [AuthApi#login] Content-Type: application/json
2022-07-25 14:12:43.574 DEBUG 1032530 --- [Executor] feign.Logger : [AuthApi#login] user-agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4464.5 Safari/537.36
2022-07-25 14:12:43.575 DEBUG 1032530 --- [Executor] feign.Logger : [AuthApi#login]
2022-07-25 14:12:43.576 DEBUG 1032530 --- [Executor] feign.Logger : [AuthApi#login] {"login":"123456789"}
2022-07-25 14:12:43.576 DEBUG 1032530 --- [Executor] feign.Logger : [AuthApi#login] ---> END HTTP (21-byte body)
2022-07-25 14:12:43.901 DEBUG 1032530 --- [Executor] feign.Logger : [AuthApi#login] <--- UNKNOWN 200 (324ms)
2022-07-25 14:12:43.901 DEBUG 1032530 --- [Executor] feign.Logger : [AuthApi#login] cache-control: no-cache
2022-07-25 14:12:43.901 DEBUG 1032530 --- [Executor] feign.Logger : [AuthApi#login] cf-cache-status: DYNAMIC
2022-07-25 14:12:43.901 DEBUG 1032530 --- [Executor] feign.Logger : [AuthApi#login] cf-ray: 730476518ea441ce-AMS
2022-07-25 14:12:43.901 DEBUG 1032530 --- [Executor] feign.Logger : [AuthApi#login] content-type: application/json
2022-07-25 14:12:43.901 DEBUG 1032530 --- [Executor] feign.Logger : [AuthApi#login] date: Mon, 25 Jul 2022 11:12:43 GMT
2022-07-25 14:12:43.901 DEBUG 1032530 --- [Executor] feign.Logger : [AuthApi#login] expect-ct: max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"
2022-07-25 14:12:43.901 DEBUG 1032530 --- [Executor] feign.Logger : [AuthApi#login] feature-policy: accelerometer 'none'; camera 'none'; geolocation 'none'; gyroscope 'none'; magnetometer 'none'; microphone 'none'; payment *; usb 'none'
2022-07-25 14:12:43.901 DEBUG 1032530 --- [Executor] feign.Logger : [AuthApi#login] referrer-policy: strict-origin-when-cross-origin
2022-07-25 14:12:43.901 DEBUG 1032530 --- [Executor] feign.Logger : [AuthApi#login] server: cloudflare
2022-07-25 14:12:43.901 DEBUG 1032530 --- [Executor] feign.Logger : [AuthApi#login] set-cookie: ACCESS_TOKEN=eyJh9uygCUMA659bAZ54SHpSNy_KFXQ; Max-Age=1800; Domain=.example.com; Path=/; Secure; SameSite=None
2022-07-25 14:12:43.901 DEBUG 1032530 --- [Executor] feign.Logger : [AuthApi#login] strict-transport-security: max-age=31536000
2022-07-25 14:12:43.901 DEBUG 1032530 --- [Executor] feign.Logger : [AuthApi#login] x-content-type-options: nosniff
2022-07-25 14:12:43.901 DEBUG 1032530 --- [Executor] feign.Logger : [AuthApi#login] x-frame-options: sameorigin
2022-07-25 14:12:43.901 DEBUG 1032530 --- [Executor] feign.Logger : [AuthApi#login] x-xss-protection: 1; mode=block
2022-07-25 14:12:43.901 DEBUG 1032530 --- [Executor] feign.Logger : [AuthApi#login]
2022-07-25 14:12:43.902 DEBUG 1032530 --- [Executor] feign.Logger : [AuthApi#login] {"status":{"code":"OK","message":"OK"},"body":{"id":"20826"}}
2022-07-25 14:12:43.902 DEBUG 1032530 --- [Executor] feign.Logger : [AuthApi#login] <--- END HTTP (61-byte body)
```
## New Normalized Logger
@ -55,8 +53,7 @@ All parts are separeted from each other:
The whole communication (request and response parts) is combined into one log entry.
```
2022-07-25 14:16:06.217 INFO 1057053 --- [Executor] com.pf.profee.api.NormalizedFeignLogger : normalized feign request {AuthApi#login(LoginRequestDto)=[AuthApi#login] }: [
2022-07-25 14:16:06.217 INFO 1057053 --- [Executor] me.bvn13.openfeign.logger.NormalizedFeignLogger : normalized feign request {AuthApi#login(LoginRequestDto)=[AuthApi#login] }: [
---> POST https://example.com/api/v1/login HTTP/1.1
Content-Length: 23
Content-Type: application/json
@ -75,7 +72,7 @@ expect-ct: max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi
feature-policy: accelerometer 'none'; camera 'none'; geolocation 'none'; gyroscope 'none'; magnetometer 'none'; microphone 'none'; payment *; usb 'none'
referrer-policy: strict-origin-when-cross-origin
server: cloudflare
set-cookie: QA_JWT_ACCESS_TOKEN=eyJhboft6rzD6Be16dXY5lgQNCzOZNFe4ra_NDIdmXlXi19hlvaQ; Max-Age=1800; Domain=.example.com; Path=/; Secure; SameSite=None
set-cookie: ACCESS_TOKEN=eyJhboft6rzD6Be16dXY5lgQNCzOZNFe4ra_NDIdmXlXi19hlvaQ; Max-Age=1800; Domain=.example.com; Path=/; Secure; SameSite=None
strict-transport-security: max-age=31536000
x-content-type-options: nosniff
x-frame-options: sameorigin
@ -84,12 +81,11 @@ x-xss-protection: 1; mode=block
{"status":{"code":"OK","message":"OK"},"body":{"id":"20826"}}
<--- END HTTP (61-byte body)
]
```
# How to use
In order to user Normalized Logger into the application they must the following.
In order to use Normalized Logger into the application they must the following.
## 0) Check the latest version
@ -103,17 +99,17 @@ for Maven
<dependency>
<groupId>me.bvn13.openfeign.logger</groupId>
<artifactId>feign-normalized-logger</artifactId>
<version>0.1.0</version>
<version>0.1.4</version>
</dependency>
```
for Gradle
```groovy
implementation 'me.bvn13.openfeign.logger:feign-normalized-logger:0.1.0'
implementation 'me.bvn13.openfeign.logger:feign-normalized-logger:0.1.4'
```
## 2) Create Feign configuration and enable logger
## 2) Create Feign configuration and enable logger + specify FULL logging level
```java
import feign.Logger;
@ -124,6 +120,11 @@ public class MyFeignConfig {
public Logger logger() {
return new NormalizedFeignLogger();
}
@Bean
public Logger.Level logLevel() {
return Logger.Level.FULL;
}
}
```
@ -137,12 +138,12 @@ public interface AuthApi {
}
```
### 4) Adjust DEBUG level for Normalized Logger
### 4) Adjust INFO level for Normalized Logger
for Slf4J + Logback
```yaml
logging:
level:
me.bvn13.openfeign.logger.NormalizedFeignLogger: DEBUG
```
me.bvn13.openfeign.logger.NormalizedFeignLogger: INFO
```

View File

@ -7,7 +7,7 @@
<groupId>me.bvn13.openfeign.logger</groupId>
<artifactId>feign-normalized-logger</artifactId>
<version>0.1.1</version>
<version>0.1.5-SNAPSHOT</version>
<packaging>jar</packaging>

15
publish.sh 100755
View File

@ -0,0 +1,15 @@
#!/bin/bash
./mvnw gitflow:release-start gitflow:release-finish
git push origin master
git push --tags
git push origin develop
read -p "Which version to publish? > " version
git checkout $version
./mvnw deploy -Prelease

View File

@ -95,7 +95,7 @@ public class NormalizedFeignLogger extends feign.Logger {
}
private void showLogs(String configKey) {
log.debug("normalized feign request " + methodName.get() + ": [\n" +
log.info("Normalized feign request " + methodName.get() + ": [\n" +
collectionToDelimitedString(logsRequest.get().getOrDefault(configKey, Collections.emptyList()), "\n") +
"\n] has response [\n" +
collectionToDelimitedString(logsResponse.get().getOrDefault(configKey, Collections.emptyList()), "\n") +