Improved time prefix
This commit is contained in:
@ -11,6 +11,7 @@ import org.java_websocket.handshake.ClientHandshake;
|
||||
import org.java_websocket.server.WebSocketServer;
|
||||
|
||||
import es.mesacarlos.webconsole.WebConsole;
|
||||
import es.mesacarlos.webconsole.util.DateTimeUtils;
|
||||
import es.mesacarlos.webconsole.util.Internationalization;
|
||||
import es.mesacarlos.webconsole.util.LoginManager;
|
||||
import es.mesacarlos.webconsole.websocket.command.WSCommandFactory;
|
||||
@ -97,7 +98,7 @@ public class WSServer extends WebSocketServer {
|
||||
Collection<WebSocket> connections = getConnections();
|
||||
for (WebSocket connection : connections) {
|
||||
if (LoginManager.getInstance().isLoggedIn(connection.getRemoteSocketAddress()))
|
||||
sendToClient(connection, new ConsoleOutput(line));
|
||||
sendToClient(connection, new ConsoleOutput(line, DateTimeUtils.getTimeAsString()));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -35,7 +35,7 @@ public class ReadLogFileCommand implements WSCommand{
|
||||
}
|
||||
|
||||
for(String line : lines)
|
||||
wsServer.sendToClient(conn, new ConsoleOutput(line));
|
||||
wsServer.sendToClient(conn, new ConsoleOutput(line, null));
|
||||
}
|
||||
|
||||
}
|
@ -4,9 +4,11 @@ import com.google.gson.JsonObject;
|
||||
|
||||
public class ConsoleOutput implements JSONOutput{
|
||||
private String message;
|
||||
private String time;
|
||||
|
||||
public ConsoleOutput(String message) {
|
||||
public ConsoleOutput(String message, String time) {
|
||||
this.message = message;
|
||||
this.time = time;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -18,12 +20,17 @@ public class ConsoleOutput implements JSONOutput{
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
public String getTime() {
|
||||
return time;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toJSON() {
|
||||
JsonObject object = new JsonObject();
|
||||
object.addProperty("status", getStatusCode());
|
||||
object.addProperty("statusDescription", "Console Output");
|
||||
object.addProperty("time", getTime());
|
||||
object.addProperty("message", getMessage());
|
||||
return object.toString();
|
||||
}
|
||||
|
Reference in New Issue
Block a user