All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.tracee.backend.jbosslogging.JbossLoggingMdcLikeAdapter Maven / Gradle / Ivy

There is a newer version: 0.11.0
Show newest version
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;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy