package pack1;

import java.io.File;
import java.io.FileWriter;

/**
 * This is a logging class written to log basic events within my code, for debug purposes. Everything
 * should theoretically work, with a few tweaks here and there.
 *
 * @author Noah Morton
 */

public class Logger {
    private static File f;

    public Logger() {

        f = new File("programLog.log");

    }


    //logs a code message, such as a creation success.
    public static void logCodeMessage(String message) {

        try {
            FileWriter fw = new FileWriter(f, true); //the true will append the new data
            fw.write("\n[Code] " + message);
            fw.close();
        } catch (Exception e) {
            System.err.println("Error with writing logging file. " + e.getMessage());
        }
    }

    //logs input of the user in the console, for recreation of bugs.
    public static void logUserMessage(String message) {
        try {
            FileWriter fw = new FileWriter(f, true); //the true will append the new data
            fw.write("\n[User] " + message);
            fw.close();
        } catch (Exception e) {
            System.err.println("Error with writing logging file. " + e.getMessage());
        }

    }

    //logs error and failure messages.
    public static void logErrorMessage(String message) {
        try {
            FileWriter fw = new FileWriter(f, true); //the true will append the new data
            fw.write("\n[Error] " + message);
            fw.close();
        } catch (Exception e) {
            System.err.println("Error with writing logging file. " + e.getMessage());

        }

    }

    //logs other messages, that don't fit into a category.
    public static void logOtherMessage(String type, String message) {

        try {
            FileWriter fw = new FileWriter(f, true); //the true will append the new data
            fw.write("\n[" + type + "] " + message);
            fw.close();
        } catch (Exception e) {
            System.err.println("Error with writing logging file. " + e.getMessage());

        }

    }

}









@@ -9,16 +9,38 @@
 pack1;%0A%0A
+import javax.swing.*;%0A
 import j
@@ -282,10 +282,51 @@
 n%0A *
-/%0A
+ @version 1.0%0A */%0A%0A@SuppressWarnings(%22ALL%22)
 %0Apub
@@ -390,25 +390,24 @@
  Logger() %7B%0A
-%0A
         f = 
@@ -434,24 +434,94 @@
 .log%22);%0A
+        Logger.logOtherMessage(%22New Run%22, %22----------------------%5Cn%22);
 %0A    %7D%0A%0A
 %0A    //l
@@ -512,23 +512,31 @@
 %0A    %7D%0A%0A
-%0A
     /
-/
+**%0A     * 
 logs a c
@@ -576,16 +576,80 @@
 uccess.%0A
+     *%0A     * @param message The message to be written.%0A     */%0A
     publ
@@ -688,33 +688,32 @@
 ring message) %7B%0A
-%0A
         try %7B%0A  
@@ -1004,25 +1004,34 @@
     %7D%0A%0A    /
-/
+**%0A     * 
 logs input o
@@ -1055,16 +1055,20 @@
  console
+/gui
 , for re
@@ -1085,16 +1085,80 @@
 f bugs.%0A
+     *%0A     * @param message The message to be written.%0A     */%0A
     publ
@@ -1514,25 +1514,34 @@
     %7D%0A%0A    /
-/
+**%0A     * 
 logs error a
@@ -1561,16 +1561,88 @@
 ssages.%0A
+     *%0A     * @param message Message to be logged after %5BError%5D%0A     */%0A
     publ
@@ -2005,17 +2005,26 @@
 %7D%0A%0A    /
-/
+**%0A     * 
 logs oth
@@ -2068,16 +2068,179 @@
 tegory.%0A
+     *%0A     * @param type    The message to be displayed inside brackets, eg. %5BWindow%5D%0A     * @param message The message to be written after the brackets.%0A     */%0A
     publ
@@ -2592,33 +2592,32 @@
 .getMessage());%0A
-%0A
         %7D%0A%0A    %7D
@@ -2622,14 +2622,590 @@
  %7D%0A%0A
-%7D%0A%0A%0A%0A%0A%0A%0A%0A%0A
+    /**%0A     * create a message window, for GUI based notices.%0A     *%0A     * @param message The message to be displayed in the window.%0A     */%0A    public static void messageWindow(String message) %7B%0A        JOptionPane.showMessageDialog(null, message);%0A    %7D%0A%0A    /**%0A     * Displays a error window.%0A     *%0A     * @param title   The title of the error window.%0A     * @param message The error message to be displayed.%0A     */%0A    public static void errorWindow(String title, String message) %7B%0A        JOptionPane.showMessageDialog(null, message, title, JOptionPane.ERROR_MESSAGE);%0A    %7D%0A%7D

Update logger.