Rolled CTX functions into Log

This commit is contained in:
Collin Smith 2020-07-26 02:12:51 -07:00
parent 8067e6fec3
commit 25b428cb04
2 changed files with 13 additions and 33 deletions

View File

@ -1,33 +0,0 @@
package com.riiablo.log;
import org.apache.logging.log4j.ThreadContext;
import com.badlogic.gdx.utils.OrderedMap;
// TODO: support ThreadLocal or convert into ThreadContextMap impl
public enum CTX {
INSTANCE;
public static void put(String key, String value) {
ThreadContext.put(key, value);
// INSTANCE.map.put(key, value);
}
public static void remove(String key) {
ThreadContext.remove(key);
// INSTANCE.map.remove(key);
}
public static void clear() {
ThreadContext.clearMap();
// INSTANCE.map.clear();
}
@Deprecated
public static OrderedMap<String, String> map() {
return null;
// return INSTANCE.map;
}
// final OrderedMap<String, String> map = new OrderedMap<>();
}

View File

@ -1,6 +1,7 @@
package com.riiablo.log;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.ThreadContext;
import org.apache.logging.log4j.message.Message;
import org.apache.logging.log4j.message.MessageFactory;
import org.apache.logging.log4j.message.StringFormatterMessageFactory;
@ -31,4 +32,16 @@ public class Log {
public static void errorf(Logger logger, Throwable t, String format, Object... args) {
logger.error(createMessage(format, args), t);
}
public static void put(String key, String value) {
ThreadContext.put(key, value);
}
public static void remove(String key) {
ThreadContext.remove(key);
}
public static void clearMap() {
ThreadContext.clearMap();
}
}