Skip to content

Commit

Permalink
Add logging for configuration properties. Update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
Kochetkov Maksim committed Feb 1, 2023
1 parent 2c46a2e commit fad6f26
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 28 deletions.
24 changes: 24 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -269,3 +269,27 @@ WEB UI is implemented with [Vaadin 14](https://vaadin.com/start/v14)
> *Main Page*
![alt text](ui-example.png)

### Logging

Logging properties are located in `[application.yaml](src%2Fmain%2Fresources%2Fapplication.yaml)`

```
logging:
level:
root: INFO
org.atmosphere: WARN # Vaadin (GUI) Server
org.springframework: INFO
org.springframework.core: WARN
org.springframework.beans.factory.support: WARN
ru.iopump.qa:allure: INFO # Allure Server Logs
```
You may override it by Environment Variables, for example enable `DEBUG` for allure server:
```
export LOGGING_LEVEL_RU_IOPUMP_QA_ALLURE=DEBUG
```
Or switch all logs to `DEBUG`:
```
export LOGGING_LEVEL_ROOT=DEBUG
```
11 changes: 11 additions & 0 deletions src/main/java/ru/iopump/qa/allure/properties/AllureProperties.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
package ru.iopump.qa.allure.properties;

import lombok.Getter;
import lombok.ToString;
import lombok.experimental.Accessors;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.context.properties.ConstructorBinding;

import javax.annotation.PostConstruct;
import java.nio.file.Path;
import java.nio.file.Paths;

Expand All @@ -14,6 +17,8 @@
@Getter
@Accessors(fluent = true)
@ConstructorBinding
@Slf4j
@ToString
public class AllureProperties {

private final Reports reports;
Expand All @@ -30,7 +35,13 @@ public AllureProperties(Reports reports, String resultsDir, boolean supportOldFo
this.serverBaseUrl = defaultIfNull(serverBaseUrl, null);
}

@PostConstruct
void init() {
log.info("[ALLURE SERVER CONFIGURATION] Main AllureProperties parameters: " + this);
}

@Getter
@ToString
public static class Reports {

private final transient Path dirPath;
Expand Down
11 changes: 11 additions & 0 deletions src/main/java/ru/iopump/qa/allure/properties/BasicProperties.java
Original file line number Diff line number Diff line change
@@ -1,16 +1,22 @@
package ru.iopump.qa.allure.properties;

import lombok.Getter;
import lombok.ToString;
import lombok.experimental.Accessors;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.context.properties.ConstructorBinding;

import javax.annotation.PostConstruct;

import static org.apache.commons.lang3.ObjectUtils.defaultIfNull;

@ConfigurationProperties(prefix = "basic.auth")
@Getter
@Accessors(fluent = true)
@ConstructorBinding
@Slf4j
@ToString(exclude = "password")
public class BasicProperties {

private final String username;
Expand All @@ -22,4 +28,9 @@ public BasicProperties(String username, String password, boolean enable) {
this.password = defaultIfNull(password, "admin");
this.enable = defaultIfNull(enable, false);
}

@PostConstruct
void init() {
log.info("[ALLURE SERVER CONFIGURATION] Authorization parameters: " + this);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ private static String print(Collection<Pair<ReportEntity, Boolean>> removedRepor
void init() throws JsonProcessingException {
final ObjectWriter prettyWriter = objectMapper.writerWithDefaultPrettyPrinter();

log.info("CleanUp policy settings:\n{}", prettyWriter.writeValueAsString(cleanUpProperties));
log.info("[ALLURE SERVER CONFIGURATION] CleanUp policy settings:\n{}", prettyWriter.writeValueAsString(cleanUpProperties));
}

@Override
Expand Down
10 changes: 9 additions & 1 deletion src/main/resources/application.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,12 @@ allure:
paths:
- path: "manual_uploaded"
ageDays: 30
server-base-url:
server-base-url:
logging:
level:
root: INFO
org.atmosphere: WARN # Vaadin (GUI) Server
org.springframework: INFO
org.springframework.core: WARN
org.springframework.beans.factory.support: WARN
ru.iopump.qa:allure: INFO # Allure Server Logs
26 changes: 0 additions & 26 deletions src/main/resources/logback.xml

This file was deleted.

0 comments on commit fad6f26

Please sign in to comment.