Skip to content

Commit

Permalink
move MDCHelper to org.slf4j
Browse files Browse the repository at this point in the history
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
  • Loading branch information
ceki committed Dec 6, 2023
1 parent 86ee829 commit 4909d1d
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 0 deletions.
39 changes: 39 additions & 0 deletions slf4j-api/src/main/java/org/slf4j/MDCHelper.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package org.slf4j;

import java.util.HashSet;
import java.util.Set;

public class MDCHelper {


Set<String> 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);
}
}
}
15 changes: 15 additions & 0 deletions slf4j-api/src/test/java/org/slf4j/MDCHelperTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package org.slf4j;

import org.junit.Test;

public class MDCHelperTest {


@Test
public void smoke() {
MDCHelper mdch = new MDCHelper();

//mdch.addKey()

}
}

0 comments on commit 4909d1d

Please sign in to comment.