-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLogger.java
More file actions
30 lines (25 loc) · 749 Bytes
/
Copy pathLogger.java
File metadata and controls
30 lines (25 loc) · 749 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import java.io.FileNotFoundException;
import java.io.PrintStream;
import java.io.UnsupportedEncodingException;
public class Logger {
private static Logger masterLogger;
private PrintStream masterLog;
private Logger() throws FileNotFoundException, UnsupportedEncodingException {
masterLog = new PrintStream("master-server.log", "UTF-8");
System.setErr(masterLog); // direct error messages to masterLog
}
public static Logger getInstance() throws FileNotFoundException,
UnsupportedEncodingException {
if (masterLogger == null) {
return masterLogger = new Logger();
} else {
return masterLogger;
}
}
public void logMessage(String msg) {
masterLog.println(msg);
}
public void closeLogger() {
masterLog.close();
}
}