Esempio n. 1
0
 public static void init() {
   try {
     Logger.writer =
         new FileWriter(
             System.getProperty("user.home")
                 + System.getProperty("file.separator")
                 + ".crumb"
                 + System.getProperty("file.separator")
                 + "crumb.log",
             true);
     Logger.writer2 =
         new FileWriter(
             System.getProperty("user.home")
                 + System.getProperty("file.separator")
                 + ".crumb"
                 + System.getProperty("file.separator")
                 + "last.log",
             false);
     Logger.writing = true;
   } catch (Exception e) {
     Logger.printErrorStack(e);
     Logger.severe("Could not write to log file.");
     Logger.writing = false;
   }
 }
Esempio n. 2
0
 private static void log(String message) {
   System.out.println(message);
   if (Logger.writing) {
     try {
       if (Logger.writer == null) Logger.init();
       else
         Logger.writer.write(
             new SimpleDateFormat("[d/M/y k:m:s] ").format(new Date()) + message + "\n");
       if (Logger.writer2 == null) Logger.init();
       else
         Logger.writer2.write(
             new SimpleDateFormat("[d/M/y k:m:s] ").format(new Date()) + message + "\n");
     } catch (Exception e) {
       Logger.printErrorStack(e);
     }
   }
 }
Esempio n. 3
0
 public static void close() {
   try {
     if (Logger.writer != null) {
       Logger.writer.close();
       Logger.writer = null;
     }
     if (Logger.writer2 != null) {
       Logger.writer2.close();
       Logger.writer2 = null;
     }
     if (Logger.writer == null && Logger.writer2 == null) {
       Logger.writing = false;
     } else {
       throw new Exception();
     }
   } catch (Exception e) {
     Logger.severe("Could not close the log file stream. Attempting again.");
     Logger.printErrorStack(e);
     Logger.close();
   }
 }