Skip to content

Commit

Permalink
Simpler log setup in core router baser class
Browse files Browse the repository at this point in the history
  • Loading branch information
martin-traverse committed Dec 8, 2024
1 parent 17c26f1 commit a926993
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,23 +62,4 @@ public static Logger threadLocalLogger(Object obj, ThreadLocal<Logger> logMap) {

return log;
}

public static Logger typedThreadLocalLogger(Object obj, ThreadLocal<Map<Class<?>, Logger>> logMap) {

var map = logMap.get();

if (map == null) {
map = new HashMap<>();
logMap.set(map);
}

var log = map.get(obj.getClass());

if (log == null) {
log = LoggerFactory.getLogger(obj.getClass());
map.put(obj.getClass(), log);
}

return log;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

package org.finos.tracdap.gateway.routing;

import org.finos.tracdap.common.util.LoggingHelpers;
import org.finos.tracdap.gateway.exec.Redirect;
import org.finos.tracdap.gateway.exec.Route;

Expand All @@ -29,6 +28,7 @@
import io.netty.util.concurrent.Future;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.net.URI;
import java.util.*;
Expand All @@ -44,9 +44,7 @@ abstract class CoreRouter extends ChannelDuplexHandler {
// As well as stability, the router is the heart of the gateway and is likely to change semi-often
// Clarity and convention make for happy coders...


private static final ThreadLocal<Map<Class<?>, Logger>> logMap = new ThreadLocal<>();
private final Logger log = LoggingHelpers.typedThreadLocalLogger(this, logMap);
private final Logger log = LoggerFactory.getLogger(getClass());

protected final List<Route> routes;
protected final List<Redirect> redirects;
Expand Down

0 comments on commit a926993

Please sign in to comment.