pull/701/head
Michael Barry 2023-10-27 20:40:45 -04:00 zatwierdzone przez GitHub
rodzic 1be2fca45f
commit 9f960022b8
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 4AEE18F83AFDEB23
2 zmienionych plików z 21 dodań i 1 usunięć

Wyświetl plik

@ -24,7 +24,8 @@ public class LogUtil {
/** Returns the current {@code [stage]} value prepended to log for this thread. */
public static String getStage() {
return MDC.get(STAGE_KEY);
// strip out the "[stage] " wrapper
return MDC.get(STAGE_KEY) instanceof String s ? s.substring(1, s.length() - 2) : null;
}
/** Prepends {@code [parent:child]} to all subsequent logs from this thread. */

Wyświetl plik

@ -0,0 +1,19 @@
package com.onthegomap.planetiler.util;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNull;
import org.junit.jupiter.api.Test;
class LogUtilTest {
@Test
void testStageHandling() {
assertNull(LogUtil.getStage());
LogUtil.setStage("test");
assertEquals("test", LogUtil.getStage());
LogUtil.setStage(LogUtil.getStage(), "child");
assertEquals("test:child", LogUtil.getStage());
LogUtil.clearStage();
assertNull(LogUtil.getStage());
}
}