From: TJ Date: Mon, 4 May 2015 17:07:53 +0000 (+0100) Subject: ServerManagement: log static ServiceAddressMap entries at startup X-Git-Url: https://iam.tj/gitweb/gitweb.cgi?p=WeStealzYourDataz.git;a=commitdiff_plain;h=fb2d9b7c5159eeaa733eac55c06989b891f702aa ServerManagement: log static ServiceAddressMap entries at startup Logs values received from the command-line and any other static entries; also remove commas from port numbers in log messages. --- diff --git a/src/uk/ac/ntu/n0521366/wsyd/management/ServerManagement.java b/src/uk/ac/ntu/n0521366/wsyd/management/ServerManagement.java index fc20cb7..30a46e8 100644 --- a/src/uk/ac/ntu/n0521366/wsyd/management/ServerManagement.java +++ b/src/uk/ac/ntu/n0521366/wsyd/management/ServerManagement.java @@ -145,6 +145,8 @@ public class ServerManagement extends javax.swing.JFrame implements NetworkMessa this._multicastAnnouncements = multicastAnnouncements; gMenuLogServiceAnnounce.setSelected(_multicastAnnouncements); // TODO: implement constructor setting IP address of SocialServer from command-line value + if (serverSocial != null) + _serviceToAddressMap.put("ServerSocial", new LastSeenHost(new InetSocketAddress(serverSocial, Network.PORTS_SERVER_SOCIAL), LastSeenHost.STATE.STATIC)); } /** * Initialise listeners and other objects that require a reference to 'this'. @@ -161,7 +163,7 @@ public class ServerManagement extends javax.swing.JFrame implements NetworkMessa public ServerManagement initListeners() throws UnknownHostException { LOGGER.addHandler(new TableModelHandler(this)); // send messages to the GUI log table LOGGER.setUseParentHandlers(false); // don't send messages to the default error stream logger of the parent - LOGGER.log(Level.INFO, "Server Management starting"); + LOGGER.logp(Level.INFO, _title, null, "Server Management starting"); _udpLogServiceSA = new WSYD_SocketAddress(Network.PORTS_SERVER_LOG, Protocol.UDP); _udpLogService = new NetworkServerUDP(_udpLogServiceSA, _title + "Log", _serviceToAddressMap, LOGGER); @@ -176,6 +178,13 @@ public class ServerManagement extends javax.swing.JFrame implements NetworkMessa // permit broadcasting to pseudo-host 'all' since this is multicast _serviceToAddressMap.put("all", new LastSeenHost(new InetSocketAddress(Network.MULTICAST_IP, Network.PORTS_MULTICAST_DISCOVERY), LastSeenHost.STATE.STATIC)); + // log any static entries in the service map + for (java.util.Map.Entry entry: this._serviceToAddressMap.getEntrySet()) { + LastSeenHost host = entry.getValue(); + if (host.state == LastSeenHost.STATE.STATIC) + LOGGER.logp(Level.FINER, _title, null, MessageFormat.format("Static Service: {0} = {1}:{2,number,#####}", entry.getKey(), host.address.getHostString(), host.address.getPort())); + } + ActionListener regularTasksActionListener = new ActionListener() { // provide a way to read the current version of the parent process object's fields ServerManagement owner;