Commit 8de5b59c23d9aafacb6ff0e4052e0c9f0930eeba

Authored by Nathanael Jourdane
1 parent 5799764b
Exists in master

Remove method and , now useless because log4j2 prints all logs in a file.

src/main/java/eu/omp/irap/vespa/epntapclient/utils/Log.java
... ... @@ -16,13 +16,8 @@
16 16  
17 17 package eu.omp.irap.vespa.epntapclient.utils;
18 18  
19   -import java.io.FileNotFoundException;
20 19 import java.io.FileWriter;
21 20 import java.io.IOException;
22   -import java.io.PrintWriter;
23   -import java.nio.file.Files;
24   -import java.nio.file.Paths;
25   -import java.nio.file.StandardOpenOption;
26 21  
27 22 import org.apache.logging.log4j.LogManager;
28 23 import org.apache.logging.log4j.Logger;
... ... @@ -41,22 +36,19 @@ public class Log {
41 36 /** The logger for this class. */
42 37 private static final Logger logger = LogManager.getLogger(EpnTapMainApp.class);
43 38  
44   - /** The log file path used by `logInFile` and `clearLogFile`. */
45   - private static String logPath = Const.TMP_DIR + "/log";
46   -
47 39 /** Constructor to hide the implicit public one. */
48 40 private Log() {
49 41 }
50 42  
51 43 /**
52 44 * Print the specified object in JSON format in a file on the temp directory. The default file
53   - * name is "log.json"
  45 + * name is "object.json"
54 46 *
55 47 * @param obj the object to print in a file.
56 48 * @return The path of the file.
57 49 */
58 50 public static String printObject(Object obj) {
59   - return printObject("log", obj);
  51 + return printObject("object", obj);
60 52 }
61 53  
62 54 /**
... ... @@ -80,34 +72,4 @@ public class Log {
80 72 return path;
81 73 }
82 74  
83   - // TODO: Use log4j FileAppender instead
84   -
85   - /**
86   - * Delete the content of the log file.
87   - */
88   - public static void clearLogFile() {
89   - try (PrintWriter writer = new PrintWriter(logPath)) {
90   - writer.print("");
91   - } catch (FileNotFoundException e) {
92   - logger.error("File " + logPath + " not found, can not clear it.", e);
93   - }
94   - }
95   -
96   - // TODO: Use log4j FileAppender instead
97   -
98   - /**
99   - * Print a message in a log file (named "log").
100   - *
101   - * @param text The text to log in the file
102   - */
103   - public static void logInFile(Object text) {
104   -
105   - try {
106   - Files.write(Paths.get(logPath), (text.toString() + "\n").getBytes(),
107   - StandardOpenOption.APPEND);
108   - } catch (IOException e) {
109   - logger.error("Can not print in the file " + logPath, e);
110   - }
111   - }
112   -
113 75 }
... ...