Add Time to logging
This commit is contained in:
parent
ceaf3f0c4a
commit
20d3caa5d3
1 changed files with 4 additions and 2 deletions
|
|
@ -16,6 +16,7 @@ import java.io.FileWriter;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
import java.time.format.DateTimeFormatter;
|
import java.time.format.DateTimeFormatter;
|
||||||
import java.util.concurrent.ExecutorService;
|
import java.util.concurrent.ExecutorService;
|
||||||
import java.util.concurrent.Executors;
|
import java.util.concurrent.Executors;
|
||||||
|
|
@ -56,7 +57,7 @@ public class VelocityLogging {
|
||||||
|
|
||||||
public void addToLogFile(String messageOrCommand, String playerName, String server) {
|
public void addToLogFile(String messageOrCommand, String playerName, String server) {
|
||||||
executor.execute(() -> {
|
executor.execute(() -> {
|
||||||
LocalDate date = LocalDate.now();
|
LocalDateTime date = LocalDateTime.now();
|
||||||
|
|
||||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy/MM/dd");
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy/MM/dd");
|
||||||
|
|
||||||
|
|
@ -68,7 +69,8 @@ public class VelocityLogging {
|
||||||
|
|
||||||
try (BufferedWriter writer = new BufferedWriter(new FileWriter(logFilePath.toFile(), true))) {
|
try (BufferedWriter writer = new BufferedWriter(new FileWriter(logFilePath.toFile(), true))) {
|
||||||
String logLine = "[" + playerName + "] " +
|
String logLine = "[" + playerName + "] " +
|
||||||
"[" + server + "]:" +
|
"[" + server + "] " +
|
||||||
|
"[UTC:" + date.format(DateTimeFormatter.ofPattern("HH:mm:ss")) + "]:" +
|
||||||
messageOrCommand;
|
messageOrCommand;
|
||||||
|
|
||||||
writer.write(logLine);
|
writer.write(logLine);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue