io.tracee.backend.jbosslogging.JbossLoggingMdcLikeAdapter Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of tracee-jboss-logging Show documentation
Show all versions of tracee-jboss-logging Show documentation
Please refer to https://github.com/tracee/tracee.
package io.tracee.backend.jbosslogging;
import io.tracee.MDCLike;
import org.jboss.logging.MDC;
import java.util.HashMap;
import java.util.Map;
final class JbossLoggingMdcLikeAdapter implements MDCLike {
@Override
public boolean containsKey(String key) {
return MDC.get(key) != null;
}
@Override
public void put(String key, String value) {
MDC.put(key, value);
}
@Override
public String get(String key) {
return (String) MDC.get(key);
}
@Override
public void remove(String key) {
MDC.remove(key);
}
@Override
public Map getCopyOfContext() {
final Map map = MDC.getMap();
final Map copy = new HashMap(map.size());
for (Map.Entry entry : map.entrySet()) {
if (!(entry.getValue() instanceof String)) continue;
copy.put(entry.getKey(), (String) entry.getValue());
}
return copy;
}
}