Skip to content

Commit

Permalink
Make a single separate log under the debugger
Browse files Browse the repository at this point in the history
  • Loading branch information
OldSerpskiStalker committed Sep 29, 2024
1 parent f6fb7d6 commit 843e0c5
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import net.minecraftforge.fml.common.event.FMLServerStoppedEvent;

import org.imesense.dynamicspawncontrol.debug.CheckDebugger;
import org.imesense.dynamicspawncontrol.technical.configs.*;
import org.imesense.dynamicspawncontrol.technical.eventprocessor.primitive.OnUpdateTimeWorld;
import org.imesense.dynamicspawncontrol.technical.eventprocessor.primitive.OnWindowTitle;
import org.imesense.dynamicspawncontrol.technical.initializer.RegisterCfgClasses;
Expand Down Expand Up @@ -194,7 +193,7 @@ public synchronized void preInit(FMLPreInitializationEvent event) throws IOExcep
globalDirectory = event.getModConfigurationDirectory();

//
Log.createLogFile(globalDirectory.getPath() + File.separator + STRUCT_FILES_DIRS.NAME_DIRECTORY);
Log.createLogFile(globalDirectory.getPath() + File.separator + STRUCT_FILES_DIRS.NAME_DIRECTORY, checkDebugger.IsRunDebugger);
Log.writeDataToLogFile(1, "Debugger is running: " + (checkDebugger.IsRunDebugger ? "true" : "false"));

//
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
package org.imesense.dynamicspawncontrol.technical.customlibrary;

import org.imesense.dynamicspawncontrol.DynamicSpawnControl;
import org.imesense.dynamicspawncontrol.technical.configs.ConfigLogFile;
import org.imesense.dynamicspawncontrol.technical.config.ConfigLogFile;

import javax.annotation.Nonnull;
import java.io.*;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
Expand Down Expand Up @@ -36,7 +35,7 @@ public final class Log
*
* @param path
*/
public static void createLogFile(final String path)
public static void createLogFile(final String path, boolean isDebugMode)
{
try
{
Expand All @@ -55,16 +54,22 @@ public static void createLogFile(final String path)
}
}

SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd_HH-mm-ss");
String currentDate = dateFormat.format(new Date());

String fileName = logsDirectory + "/log_" + currentDate + DynamicSpawnControl.STRUCT_FILES_EXTENSION.LOG_FILE_EXTENSION;
logFile = new File(fileName);
if (isDebugMode)
{
logFile = new File(logsDirectory, "log_debug.txt");
}
else
{
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd_HH-mm-ss");
String currentDate = dateFormat.format(new Date());
String fileName = logsDirectory + "/log_" + currentDate + DynamicSpawnControl.STRUCT_FILES_EXTENSION.LOG_FILE_EXTENSION;
logFile = new File(fileName);
}

FileWriter writer = new FileWriter(logFile);
FileWriter writer = new FileWriter(logFile, !isDebugMode);

writer.write("*********************************************************************");
writer.write("\n** Log file created: " + currentDate);
writer.write("\n** Log file created: " + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
writer.write("\n** DynamicsSpawnControl. Authors: OldSerpskiStalker, acidicMercury8");
writer.write("\n*******************************************************************");

Expand Down

0 comments on commit 843e0c5

Please sign in to comment.