doc: removed explicit thread names from logging messages

This commit is contained in:
Yannik Bretschneider 2021-06-04 19:55:21 +02:00
parent e1a3e05d28
commit c3f3fc0011
6 changed files with 23 additions and 52 deletions

View File

@ -72,13 +72,11 @@ public class Lobby {
badRequests = 0;
}
Logger.info("{}: got {} requests from participant {}",
Thread.currentThread().getName(),
Logger.info("got {} requests from participant {}",
requests.length,
source);
Logger.trace("{}: Processing requests through pipeline",
Thread.currentThread().getName());
Logger.trace("Processing requests through pipeline");
Optional<Event[]> resultingEvents = pipeline.processRequests(requests, source);
Logger.debug("generated {} events from the pipeline", resultingEvents.map(x -> x.length).orElse(0));

View File

@ -20,13 +20,9 @@ public class DisconnectSegment implements Segment {
@Override
public void processRequests(Packet packet, List<Event> carrier, AtomicBoolean abort) {
Logger.trace("{}: DisconnectSegment received {} requests.",
Thread.currentThread().getName(),
packet.size());
Logger.trace("DisconnectSegment received {} requests.", packet.size());
if (packet.containsRequestOfType(RequestType.DisconnectRequest)) {
Logger.debug("{}: Player of Type {} sent DisconnectRequest",
Thread.currentThread().getName(),
packet.getOrigin().type);
Logger.debug("Player of Type {} sent DisconnectRequest", packet.getOrigin().type);
parent.connection.removePlayer(packet.getOrigin());
if (packet.getOrigin().type != ParticipantType.Spectator) {

View File

@ -20,21 +20,15 @@ public class GameStateSegment implements Segment {
@Override
public void processRequests(Packet packet, List<Event> carrier, AtomicBoolean abort) {
Logger.trace("{}: GameStateSegment received {} requests.",
Thread.currentThread().getName(),
packet.size());
Logger.trace("GameStateSegment received {} requests.", packet.size());
var result = game.checkRequestsAndApply(packet);
Logger.trace("{}: GameLogic generated {} events",
Thread.currentThread().getName(),
result.map(List::size).orElse(0));
Logger.trace("GameLogic generated {} events", result.map(List::size).orElse(0));
if (result.isPresent()) {
Logger.trace("{}: Result from GameLogic is present. Adding requests to carrier.",
Thread.currentThread().getName());
Logger.trace("Result from GameLogic is present. Adding requests to carrier.");
carrier.addAll(result.get());
packet.clear();
} else {
Logger.debug("{}: Result from GameLogic is invalid. Triggering error.",
Thread.currentThread().getName());
Logger.debug("Result from GameLogic is invalid. Triggering error.");
abort.set(true);
}
}

View File

@ -60,49 +60,40 @@ public class PauseSegment implements Segment {
*/
@Override
public void processRequests(Packet packet, List<Event> carrier, AtomicBoolean abort) {
Logger.trace("{}: PauseSegment received {} requests. PausedState is {}",
Thread.currentThread().getName(),
Logger.trace("PauseSegment received {} requests. PausedState is {}",
packet.size(),
paused);
// check if there is a pause request (either start or stop)
if (packet.contains(new RequestBuilder(RequestType.PauseStartRequest).buildGameRequest())) {
Logger.trace("{}: PauseStartRequest found",
Thread.currentThread().getName());
Logger.trace("PauseStartRequest found");
if (!paused) {
// pause the game
pauseGame();
// create a new PauseStartEvent
carrier.add(new EventBuilder(EventType.PauseStartEvent).buildGameEvent());
Logger.trace("{}: Added PauseStartEvent to pipeline carrier",
Thread.currentThread().getName());
Logger.trace("Added PauseStartEvent to pipeline carrier");
} else { // if the game is already paused
Logger.info("{}: PauseStartRequest sent even though the game wasn't paused. Error triggered.",
Thread.currentThread().getName());
Logger.info("PauseStartRequest sent even though the game wasn't paused. Error triggered.");
abort.set(true);
return;
}
} else if (packet.contains(new RequestBuilder(RequestType.PauseStopRequest).buildGameRequest())) {
Logger.trace("{}: PauseStopRequest found",
Thread.currentThread().getName());
Logger.trace("PauseStopRequest found");
if (paused) {
pauseEnd();
Logger.debug("{}: Game unpaused.",
Thread.currentThread().getName());
Logger.debug("Game unpaused.");
// create a new PauseStartRequest
carrier.add(new EventBuilder(EventType.PauseStopEvent).buildGameEvent());
Logger.trace("{}: Added PauseStopEvent to pipeline carrier",
Thread.currentThread().getName());
Logger.trace("Added PauseStopEvent to pipeline carrier");
} else { // if the game is not paused
Logger.info("{}: PauseStopRequest sent even though the game wasn't paused. Error triggered.",
Thread.currentThread().getName());
Logger.info("PauseStopRequest sent even though the game wasn't paused. Error triggered.");
abort.set(true);
return;
}
}
if (paused) {
Logger.trace("{}: As the game is paused, Requests are removed.",
Thread.currentThread().getName());
Logger.trace("As the game is paused, Requests are removed.");
packet.removeRequestsOfTypes(
RequestType.MeleeAttackRequest,
RequestType.RangedAttackRequest,

View File

@ -38,8 +38,7 @@ public class Pipeline {
* {@link Optional#isEmpty()} or {@link Optional#isPresent()}, and act accordingly.
*/
public Optional<Event[]> processRequests(Request[] requests, Participant origin) {
Logger.trace("{}: Pipeline started RequestProcessing",
Thread.currentThread().getName());
Logger.trace("Pipeline started RequestProcessing");
// The packet carries the requests, and gets smaller per segment
Packet packet = new Packet(requests, origin);
// The packet is filled by the requests resulting from events per segment
@ -47,8 +46,7 @@ public class Pipeline {
// The abort boolean describes whether an abort happened in a segment
AtomicBoolean abort = new AtomicBoolean(false);
Logger.trace("{}: Iterating through segments",
Thread.currentThread().getName());
Logger.trace("Iterating through segments");
// Loop through all segments
for (Segment segment: segments) {
// Give the segment the packet, carrier and abort, and let it process requests
@ -58,13 +56,10 @@ public class Pipeline {
}
}
if (abort.get()) { // if abort is true, return empty optional
Logger.debug("{}: Abort triggered in Pipeline",
Thread.currentThread().getName());
Logger.debug("Abort triggered in Pipeline");
return Optional.empty();
} else { // else return an optional of the array
Logger.trace("{}: Pipeline executed normally. Returning {} events.",
Thread.currentThread().getName(),
carrier.size());
Logger.trace("Pipeline executed normally. Returning {} events.", carrier.size());
return Optional.of(carrier.toArray(new Event[0]));
}
}

View File

@ -20,12 +20,9 @@ public class RequestGameStateSegment implements Segment {
@Override
public void processRequests(Packet packet, List<Event> carrier, AtomicBoolean abort) {
Logger.trace("{}: RequestGameStateSegment received {} requests",
Thread.currentThread().getName(),
packet.size());
Logger.trace("RequestGameStateSegment received {} requests", packet.size());
if (packet.containsRequestOfType(RequestType.Req)) {
Logger.trace("{}: Req event found. Returning Gamestate, and clearing entire RequestList",
Thread.currentThread().getName());
Logger.trace("Req event found. Returning Gamestate, and clearing entire RequestList");
carrier.add(game.getGameStateEvent());
packet.clear();
}