Skip to content

Commit

Permalink
Merge pull request #1597 from Windchild292/dev_Windchild_ResetLogFile
Browse files Browse the repository at this point in the history
MegaMek Log File is Reset on MekHQ load
  • Loading branch information
sixlettervariables authored Mar 29, 2020
2 parents ec09191 + 7f3229b commit 5646d57
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions MekHQ/src/mekhq/MekHQ.java
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ public class MekHQ implements GameListener {
public static String CAMPAIGN_DIRECTORY = "./campaigns/";
public static String PREFERENCES_FILE = "mmconf/mekhq.preferences";
public static String PRESET_DIR = "./mmconf/mhqPresets/";
public static String DEFAULT_LOG_FILE_NAME = "mekhqlog.txt";

private static final EventBus EVENT_BUS = new EventBus();

Expand Down Expand Up @@ -365,11 +366,16 @@ public static void main(String[] args) {
System.setProperty("apple.laf.useScreenMenuBar", "true");
System.setProperty("com.apple.mrj.application.apple.menu.about.name","MekHQ");

// TODO : logFileName should probably not be inline
String logFileName = "logs" + File.separator + "mekhqlog.txt";
getLogger().resetLogFile(logFileName);
// We need to reset both the MekHQ and MegaMek log files for now, as we route output to them
// both
String logFileNameMHQ = PreferenceManager.getClientPreferences().getLogDirectory()
+ File.separator + DEFAULT_LOG_FILE_NAME;
String logFileNameMM = PreferenceManager.getClientPreferences().getLogDirectory()
+ File.separator + MegaMek.DEFAULT_LOG_FILE_NAME;
getLogger().resetLogFile(logFileNameMHQ);
getLogger().resetLogFile(logFileNameMM);
// redirect output to log file
redirectOutput(logFileName); // Deprecated call required for MegaMek usage
redirectOutput(logFileNameMHQ); // Deprecated call required for MegaMek usage

SwingUtilities.invokeLater(() -> MekHQ.getInstance().startup());
}
Expand Down

0 comments on commit 5646d57

Please sign in to comment.