diff --git a/slf4j-api/src/main/java/org/slf4j/MDCHelper.java b/slf4j-api/src/main/java/org/slf4j/MDCHelper.java new file mode 100644 index 000000000..81d645a9b --- /dev/null +++ b/slf4j-api/src/main/java/org/slf4j/MDCHelper.java @@ -0,0 +1,39 @@ +package org.slf4j; + +import java.util.HashSet; +import java.util.Set; + +public class MDCHelper { + + + Set keySet = new HashSet(); + + public MDCHelper() { + + } + + public MDCHelper put(String key, String value) { + MDC.put(key, value); + keySet.add(key); + return this; + } + + public MDCHelper addKey(String key) { + keySet.add(key); + return this; + } + + public MDCHelper addKeys(String... keys) { + for(String k: keys) { + keySet.add(k); + } + return this; + } + + + public void removeSet() { + for(String key: keySet) { + MDC.remove(key); + } + } +} diff --git a/slf4j-api/src/test/java/org/slf4j/MDCHelperTest.java b/slf4j-api/src/test/java/org/slf4j/MDCHelperTest.java new file mode 100644 index 000000000..4dc166272 --- /dev/null +++ b/slf4j-api/src/test/java/org/slf4j/MDCHelperTest.java @@ -0,0 +1,15 @@ +package org.slf4j; + +import org.junit.Test; + +public class MDCHelperTest { + + + @Test + public void smoke() { + MDCHelper mdch = new MDCHelper(); + + //mdch.addKey() + + } +}