Skip to content

Commit

Permalink
feat: small improvements on logging
Browse files Browse the repository at this point in the history
  • Loading branch information
Scoppio committed Dec 10, 2024
1 parent e51d9fb commit e9072d7
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 30 deletions.
16 changes: 7 additions & 9 deletions MekHQ/mmconf/log4j2.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
</Properties>

<Appenders>
<Console name="Console">
<Console name="dev">
<PatternLayout pattern="${layout}" />
</Console>
<File name="MegaMekLog" fileName="logs/megamek.log" append="false">
Expand All @@ -17,32 +17,30 @@
<File name="MekHQLog" fileName="logs/mekhq.log" append="false">
<PatternLayout pattern="${layout}" />
</File>
<Null name="null" />
</Appenders>

<Loggers>
<logger name="java.io.serialization" level="DEBUG" additivity="false">
<appender-ref ref="Console" />
</logger>
<Logger name="megamek.client.bot" level="error" additivity="false">
<AppenderRef ref="MegaMekLog" />
<AppenderRef ref="Console" />
<AppenderRef ref="${env:profile:-null}" />
</Logger>
<Logger name="megamek" level="info" additivity="false">
<AppenderRef ref="MegaMekLog" />
<AppenderRef ref="Console" />
<AppenderRef ref="${env:profile:-null}" />
</Logger>
<Logger name="megameklab" level="info" additivity="false">
<AppenderRef ref="MegaMekLabLog" />
<AppenderRef ref="Console" />
<AppenderRef ref="${env:profile:-null}" />
</Logger>
<Logger name="mekhq" level="info" additivity="false">
<AppenderRef ref="MekHQLog" />
<AppenderRef ref="Console" />
<AppenderRef ref="${env:profile:-null}" />
</Logger>

<Root level="info">
<AppenderRef ref="MegaMekLog" />
<AppenderRef ref="Console" />
<AppenderRef ref="${env:profile:-null}" />
</Root>
</Loggers>
</Configuration>
2 changes: 1 addition & 1 deletion MekHQ/resources/log4j2.component.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
log4j2.configurationFile=mmconf/log4j2.xml
log4j2.configurationFile=mmconf/log4j2.xml
Original file line number Diff line number Diff line change
Expand Up @@ -134,27 +134,11 @@ public void addReport(ReportEntry r) {
@Override
public void calculatePlayerInitialCounts() {
for (Player player : game.getPlayersList()) {
long count = 0;
for (AcsFormation formation : game.getActiveFormations(player)) {
if (!formation.isRouted()) {
count++;
}
}
player.setInitialEntityCount(Math.toIntExact(count));

int totalBV = 0;
for (AcsFormation formation : game.getActiveFormations(player)) {
totalBV += formation.getPointValue();
}
player.setInitialBV(totalBV);
player.setInitialEntityCount(Math.toIntExact(game.getActiveFormations(player).stream()
.filter(entity -> !entity.isRouted()).count()));
game.getActiveFormations(player).stream().map(AcsFormation::getPointValue).reduce(Integer::sum)
.ifPresent(player::setInitialBV);
}

// for (Player player : game.getPlayersList()) {
// player.setInitialEntityCount(Math.toIntExact(game.getActiveFormations(player).stream()
// .filter(entity -> !entity.isRouted()).count()));
// game.getActiveFormations(player).stream().map(AcsFormation::getPointValue).reduce(Integer::sum)
// .ifPresent(player::setInitialBV);
// }
}


Expand Down

0 comments on commit e9072d7

Please sign in to comment.