kopia lustrzana https://github.com/onthegomap/planetiler
Logging fix (#699)
rodzic
1be2fca45f
commit
9f960022b8
|
@ -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. */
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
}
|
Ładowanie…
Reference in New Issue