Skip to content

Commit

Permalink
Better logging of env vars and odh constants
Browse files Browse the repository at this point in the history
Signed-off-by: David Kornel <[email protected]>
  • Loading branch information
kornys committed Jan 15, 2024
1 parent 6327a4d commit 78d7a3a
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 248 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ target/
!**/src/main/**/target/
!**/src/test/**/target/
src/main/resources/install-files
pom.xml.versionsBackup*

### IntelliJ IDEA ###
.idea/
Expand Down
243 changes: 0 additions & 243 deletions pom.xml.versionsBackup

This file was deleted.

2 changes: 2 additions & 0 deletions src/main/java/io/odh/test/Environment.java
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ private Environment() {

static {
String debugFormat = "{}: {}";
LoggerUtils.logSeparator("-", 30);
LOGGER.info("Used environment variables:");
VALUES.entrySet().stream()
.sorted(Map.Entry.comparingByKey())
Expand All @@ -107,6 +108,7 @@ private Environment() {
LOGGER.info(debugFormat, entry.getKey(), entry.getValue());
}
});
LoggerUtils.logSeparator("-", 30);
}

public static void print() {
Expand Down
24 changes: 24 additions & 0 deletions src/main/java/io/odh/test/LoggerUtils.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
* Copyright Skodjob authors.
* License: Apache License 2.0 (see the file LICENSE or http://apache.org/licenses/LICENSE-2.0.html).
*/
package io.odh.test;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.Collections;

public class LoggerUtils {

private static final Logger LOGGER = LoggerFactory.getLogger(LoggerUtils.class);
static final String SEPARATOR_CHAR = "#";

public static void logSeparator() {
logSeparator(SEPARATOR_CHAR, 76);
}

public static void logSeparator(String delimiterChar, int length) {
LOGGER.info(String.join("", Collections.nCopies(length, delimiterChar)));
}
}
2 changes: 2 additions & 0 deletions src/main/java/io/odh/test/OdhConstants.java
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ private static <T> T getOdhOrRhoai(String var, T odhValue, T rhoaiValue) {

static {
String debugFormat = "{}: {}";
LoggerUtils.logSeparator("-", 30);
LOGGER.info("Used OdhConstants:");
VALUES.entrySet().stream()
.sorted(Map.Entry.comparingByKey())
Expand All @@ -93,5 +94,6 @@ private static <T> T getOdhOrRhoai(String var, T odhValue, T rhoaiValue) {
LOGGER.info(debugFormat, entry.getKey(), entry.getValue());
}
});
LoggerUtils.logSeparator("-", 30);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,21 @@
package io.odh.test.framework.listeners;

import io.odh.test.framework.ExtensionContextParameterResolver;
import io.odh.test.LoggerUtils;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.extension.ExtendWith;
import org.junit.jupiter.api.extension.ExtensionContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.Collections;

@ExtendWith(ExtensionContextParameterResolver.class)
public interface TestVisualSeparator {
Logger LOGGER = LoggerFactory.getLogger(TestVisualSeparator.class);
String SEPARATOR_CHAR = "#";

@BeforeEach
default void beforeEachTest(ExtensionContext testContext) {
LOGGER.info(String.join("", Collections.nCopies(76, SEPARATOR_CHAR)));
LoggerUtils.logSeparator();
LOGGER.info(String.format("%s.%s-STARTED", testContext.getRequiredTestClass().getName(),
testContext.getDisplayName().replace("()", "")));
}
Expand All @@ -30,6 +28,6 @@ default void beforeEachTest(ExtensionContext testContext) {
default void afterEachTest(ExtensionContext testContext) {
LOGGER.info(String.format("%s.%s-FINISHED", testContext.getRequiredTestClass().getName(),
testContext.getDisplayName().replace("()", "")));
LOGGER.info(String.join("", Collections.nCopies(76, SEPARATOR_CHAR)));
LoggerUtils.logSeparator();
}
}

0 comments on commit 78d7a3a

Please sign in to comment.