Skip to content

Commit 8ac0e98

Browse files
committed
Changed logging severity for some common messages. This allows implementing
a custom logger using e.g. Java.util.logging and maintaining control over what log messages are written
1 parent 3dffe82 commit 8ac0e98

File tree

3 files changed

+8
-5
lines changed

3 files changed

+8
-5
lines changed

src/nl/uu/cs/iss/ga/sim2apl/core/agent/Agent.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import java.net.URISyntaxException;
1919
import java.util.*;
2020
import java.util.concurrent.ConcurrentLinkedQueue;
21+
import java.util.logging.Level;
2122

2223

2324
/**
@@ -230,7 +231,7 @@ private void checkWhetherToReschedule(){
230231
if (!this.State.isActive()) {
231232
this.State = FIPAAgentState.ACTIVE;
232233
this.rescheduler.wakeUp();
233-
Platform.getLogger().log(Agent.class, "Agent " + getAID().getName() + " woken up");
234+
Platform.getLogger().log(Agent.class, Level.FINER, "Agent " + getAID().getName() + " woken up");
234235
}
235236
}
236237

src/nl/uu/cs/iss/ga/sim2apl/core/deliberation/DeliberationRunnable.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import java.util.List;
1111
import java.util.Objects;
1212
import java.util.concurrent.Callable;
13+
import java.util.logging.Level;
1314
import java.util.stream.Collectors;
1415

1516
/**
@@ -75,7 +76,7 @@ public List<T> call(){
7576
if (!this.agent.checkSleeping()) { // If the agents goes to sleep then it will be woken upon any external input (message, external trigger)
7677
reschedule();
7778
} else {
78-
Platform.getLogger().log(DeliberationRunnable.class, String.format("Agent %s going to sleep",
79+
Platform.getLogger().log(DeliberationRunnable.class, Level.FINER, String.format("Agent %s going to sleep",
7980
agent.getAID().getName()));
8081
}
8182
}

src/nl/uu/cs/iss/ga/sim2apl/core/platform/Platform.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import java.net.URISyntaxException;
1818
import java.net.UnknownHostException;
1919
import java.util.*;
20+
import java.util.logging.Level;
2021

2122
/**
2223
* A Platform is a container that maintains the available thread pool, agent factories,
@@ -167,7 +168,7 @@ public final int getPort() {
167168
//////////////////////////
168169

169170
public synchronized void register(Agent agent) {
170-
getLogger().log(getClass(), "Registering agent " + agent.getAID().getUuID());
171+
getLogger().log(getClass(), Level.FINEST, "Registering agent " + agent.getAID().getUuID());
171172

172173
DeliberationRunnable deliberationRunnable = new DeliberationRunnable(agent, this);
173174
AgentKillSwitch killSwitch = new AgentKillSwitch(agent);
@@ -185,7 +186,7 @@ public synchronized void register(Agent agent) {
185186
}
186187

187188
public synchronized void deregister(Agent agent) {
188-
getLogger().log(getClass(), "Deregistering agent " + agent.getAID().getUuID());
189+
getLogger().log(getClass(), Level.FINEST, "Deregistering agent " + agent.getAID().getUuID());
189190

190191
this.agentKillSwitches.remove(agent.getAID());
191192
this.registeredAgents.remove(agent.getAID());
@@ -195,7 +196,7 @@ public synchronized void deregister(Agent agent) {
195196
}
196197

197198
public synchronized void modify(AgentID oldID, Agent agent) {
198-
getLogger().log(getClass(), "Modifying agent " + agent.getAID().getUuID());
199+
getLogger().log(getClass(), Level.FINEST, "Modifying agent " + agent.getAID().getUuID());
199200

200201
AgentKillSwitch killSwitch = this.agentKillSwitches.remove(oldID);
201202
this.agentKillSwitches.put(agent.getAID(), killSwitch);

0 commit comments

Comments
 (0)