static void init(String portStr, String configFile, String dirStr) { try { port = Integer.parseInt(portStr); } catch(java.lang.NumberFormatException e) { e.printStackTrace(); usage("Could not interpret port number ["+ portStr +"]."); } PropertyConfigurator.configure(configFile); File dir = new File(dirStr); if(!dir.isDirectory()) { usage("["+dirStr+"] is not a directory."); } server = new SocketServer(dir); }
public static void main(String argv[]) { if(argv.length == 3) init(argv[0], argv[1], argv[2]); else usage("Wrong number of arguments."); try { cat.info("Listening on port " + port); ServerSocket serverSocket = new ServerSocket(port); while(true) { cat.info("Waiting to accept a new client."); Socket socket = serverSocket.accept(); InetAddress inetAddress = socket.getInetAddress(); cat.info("Connected to client at " + inetAddress); LoggerRepository h = (LoggerRepository) server.hierarchyMap.get(inetAddress); if(h == null) { h = server.configureHierarchy(inetAddress); } cat.info("Starting new socket node."); new Thread(new SocketNode(socket, h)).start(); } } catch(Exception e) { e.printStackTrace(); } }
LoggerRepository configureHierarchy(InetAddress inetAddress) { cat.info("Locating configuration file for "+inetAddress); // We assume that the toSting method of InetAddress returns is in // the format hostname/d1.d2.d3.d4 e.g. torino/192.168.1.1 String s = inetAddress.toString(); int i = s.indexOf("/"); if(i == -1) { cat.warn("Could not parse the inetAddress ["+inetAddress+ "]. Using default hierarchy."); return genericHierarchy(); } else { String key = s.substring(0, i); File configFile = new File(dir, key+CONFIG_FILE_EXT); if(configFile.exists()) { Hierarchy h = new Hierarchy(new RootLogger(Level.DEBUG)); hierarchyMap.put(inetAddress, h); new PropertyConfigurator().doConfigure(configFile.getAbsolutePath(), h); return h; } else { cat.warn("Could not find config file ["+configFile+"]."); return genericHierarchy(); } } }
public static void main(String argv[]) { if(argv.length == 3) { init(argv[0], argv[1], argv[2]); } else { usage("Wrong number of arguments."); } try { cat.info("Listening on port " + port); ServerSocket serverSocket = new ServerSocket(port); while(true) { cat.info("Waiting to accept a new client."); Socket socket = serverSocket.accept(); InetAddress inetAddress = socket.getInetAddress(); cat.info("Connected to client at " + inetAddress); LoggerRepository h = (LoggerRepository) server.hierarchyMap.get(inetAddress); if(h == null) { h = server.configureHierarchy(inetAddress); } cat.info("Starting new socket node."); new Thread(new SocketNode(socket, h)).start(); } } catch(Exception e) { e.printStackTrace(); } }
static void init(String portStr, String configFile, String dirStr) { try { port = Integer.parseInt(portStr); } catch(java.lang.NumberFormatException e) { e.printStackTrace(); usage("Could not interpret port number ["+ portStr +"]."); } PropertyConfigurator.configure(configFile); File dir = new File(dirStr); if(!dir.isDirectory()) { usage("["+dirStr+"] is not a directory."); } server = new SocketServer(dir); }
LoggerRepository configureHierarchy(InetAddress inetAddress) { cat.info("Locating configuration file for "+inetAddress); // We assume that the toSting method of InetAddress returns is in // the format hostname/d1.d2.d3.d4 e.g. torino/192.168.1.1 String s = inetAddress.toString(); int i = s.indexOf("/"); if(i == -1) { cat.warn("Could not parse the inetAddress ["+inetAddress+ "]. Using default hierarchy."); return genericHierarchy(); } else { String key = s.substring(0, i); File configFile = new File(dir, key+CONFIG_FILE_EXT); if(configFile.exists()) { Hierarchy h = new Hierarchy(new RootLogger(Level.DEBUG)); hierarchyMap.put(inetAddress, h); new PropertyConfigurator().doConfigure(configFile.getAbsolutePath(), h); return h; } else { cat.warn("Could not find config file ["+configFile+"]."); return genericHierarchy(); } } }
public static void main(String argv[]) { if(argv.length == 3) init(argv[0], argv[1], argv[2]); else usage("Wrong number of arguments."); try { cat.info("Listening on port " + port); ServerSocket serverSocket = new ServerSocket(port); while(true) { cat.info("Waiting to accept a new client."); Socket socket = serverSocket.accept(); InetAddress inetAddress = socket.getInetAddress(); cat.info("Connected to client at " + inetAddress); LoggerRepository h = (LoggerRepository) server.hierarchyMap.get(inetAddress); if(h == null) { h = server.configureHierarchy(inetAddress); } cat.info("Starting new socket node."); new Thread(new SocketNode(socket, h)).start(); } } catch(Exception e) { e.printStackTrace(); } }
static void init(String portStr, String configFile, String dirStr) { try { port = Integer.parseInt(portStr); } catch(java.lang.NumberFormatException e) { e.printStackTrace(); usage("Could not interpret port number ["+ portStr +"]."); } PropertyConfigurator.configure(configFile); File dir = new File(dirStr); if(!dir.isDirectory()) { usage("["+dirStr+"] is not a directory."); } server = new SocketServer(dir); }
LoggerRepository configureHierarchy(InetAddress inetAddress) { cat.info("Locating configuration file for "+inetAddress); // We assume that the toSting method of InetAddress returns is in // the format hostname/d1.d2.d3.d4 e.g. torino/192.168.1.1 String s = inetAddress.toString(); int i = s.indexOf("/"); if(i == -1) { cat.warn("Could not parse the inetAddress ["+inetAddress+ "]. Using default hierarchy."); return genericHierarchy(); } else { String key = s.substring(0, i); File configFile = new File(dir, key+CONFIG_FILE_EXT); if(configFile.exists()) { Hierarchy h = new Hierarchy(new RootLogger((Level) Priority.DEBUG)); hierarchyMap.put(inetAddress, h); new PropertyConfigurator().doConfigure(configFile.getAbsolutePath(), h); return h; } else { cat.warn("Could not find config file ["+configFile+"]."); return genericHierarchy(); } } }
public static void main(String argv[]) { if(argv.length == 3) init(argv[0], argv[1], argv[2]); else usage("Wrong number of arguments."); try { cat.info("Listening on port " + port); ServerSocket serverSocket = new ServerSocket(port); while(true) { cat.info("Waiting to accept a new client."); Socket socket = serverSocket.accept(); InetAddress inetAddress = socket.getInetAddress(); cat.info("Connected to client at " + inetAddress); LoggerRepository h = (LoggerRepository) server.hierarchyMap.get(inetAddress); if(h == null) { h = server.configureHierarchy(inetAddress); } cat.info("Starting new socket node."); new Thread(new SocketNode(socket, h)).start(); } } catch(Exception e) { e.printStackTrace(); } }
static void init(String portStr, String configFile, String dirStr) { try { port = Integer.parseInt(portStr); } catch(java.lang.NumberFormatException e) { e.printStackTrace(); usage("Could not interpret port number ["+ portStr +"]."); } PropertyConfigurator.configure(configFile); File dir = new File(dirStr); if(!dir.isDirectory()) { usage("["+dirStr+"] is not a directory."); } server = new SocketServer(dir); }
LoggerRepository configureHierarchy(InetAddress inetAddress) { cat.info("Locating configuration file for "+inetAddress); // We assume that the toSting method of InetAddress returns is in // the format hostname/d1.d2.d3.d4 e.g. torino/192.168.1.1 String s = inetAddress.toString(); int i = s.indexOf("/"); if(i == -1) { cat.warn("Could not parse the inetAddress ["+inetAddress+ "]. Using default hierarchy."); return genericHierarchy(); } else { String key = s.substring(0, i); File configFile = new File(dir, key+CONFIG_FILE_EXT); if(configFile.exists()) { Hierarchy h = new Hierarchy(new RootLogger(Level.DEBUG)); hierarchyMap.put(inetAddress, h); new PropertyConfigurator().doConfigure(configFile.getAbsolutePath(), h); return h; } else { cat.warn("Could not find config file ["+configFile+"]."); return genericHierarchy(); } } }
public static void main(String argv[]) { if(argv.length == 3) init(argv[0], argv[1], argv[2]); else usage("Wrong number of arguments."); try { cat.info("Listening on port " + port); ServerSocket serverSocket = new ServerSocket(port); while(true) { cat.info("Waiting to accept a new client."); Socket socket = serverSocket.accept(); InetAddress inetAddress = socket.getInetAddress(); cat.info("Connected to client at " + inetAddress); LoggerRepository h = (LoggerRepository) server.hierarchyMap.get(inetAddress); if(h == null) { h = server.configureHierarchy(inetAddress); } cat.info("Starting new socket node."); new Thread(new SocketNode(socket, h)).start(); } } catch(Exception e) { e.printStackTrace(); } }
static void init(String portStr, String configFile, String dirStr) { try { port = Integer.parseInt(portStr); } catch(java.lang.NumberFormatException e) { e.printStackTrace(); usage("Could not interpret port number ["+ portStr +"]."); } PropertyConfigurator.configure(configFile); File dir = new File(dirStr); if(!dir.isDirectory()) { usage("["+dirStr+"] is not a directory."); } server = new SocketServer(dir); }
LoggerRepository configureHierarchy(InetAddress inetAddress) { cat.info("Locating configuration file for "+inetAddress); // We assume that the toSting method of InetAddress returns is in // the format hostname/d1.d2.d3.d4 e.g. torino/192.168.1.1 String s = inetAddress.toString(); int i = s.indexOf("/"); if(i == -1) { cat.warn("Could not parse the inetAddress ["+inetAddress+ "]. Using default hierarchy."); return genericHierarchy(); } else { String key = s.substring(0, i); File configFile = new File(dir, key+CONFIG_FILE_EXT); if(configFile.exists()) { Hierarchy h = new Hierarchy(new RootLogger(Level.DEBUG)); hierarchyMap.put(inetAddress, h); new PropertyConfigurator().doConfigure(configFile.getAbsolutePath(), h); return h; } else { cat.warn("Could not find config file ["+configFile+"]."); return genericHierarchy(); } } }
public static void main(String argv[]) { if(argv.length == 3) init(argv[0], argv[1], argv[2]); else usage("Wrong number of arguments."); try { cat.info("Listening on port " + port); ServerSocket serverSocket = new ServerSocket(port); while(true) { cat.info("Waiting to accept a new client."); Socket socket = serverSocket.accept(); InetAddress inetAddress = socket.getInetAddress(); cat.info("Connected to client at " + inetAddress); LoggerRepository h = (LoggerRepository) server.hierarchyMap.get(inetAddress); if(h == null) { h = server.configureHierarchy(inetAddress); } cat.info("Starting new socket node."); new Thread(new SocketNode(socket, h)).start(); } } catch(Exception e) { e.printStackTrace(); } }
static void init(String portStr, String configFile, String dirStr) { try { port = Integer.parseInt(portStr); } catch(java.lang.NumberFormatException e) { e.printStackTrace(); usage("Could not interpret port number ["+ portStr +"]."); } PropertyConfigurator.configure(configFile); File dir = new File(dirStr); if(!dir.isDirectory()) { usage("["+dirStr+"] is not a directory."); } server = new SocketServer(dir); }
LoggerRepository configureHierarchy(InetAddress inetAddress) { cat.info("Locating configuration file for "+inetAddress); // We assume that the toSting method of InetAddress returns is in // the format hostname/d1.d2.d3.d4 e.g. torino/192.168.1.1 String s = inetAddress.toString(); int i = s.indexOf("/"); if(i == -1) { cat.warn("Could not parse the inetAddress ["+inetAddress+ "]. Using default hierarchy."); return genericHierarchy(); } else { String key = s.substring(0, i); File configFile = new File(dir, key+CONFIG_FILE_EXT); if(configFile.exists()) { Hierarchy h = new Hierarchy(new RootLogger(Level.DEBUG)); hierarchyMap.put(inetAddress, h); new PropertyConfigurator().doConfigure(configFile.getAbsolutePath(), h); return h; } else { cat.warn("Could not find config file ["+configFile+"]."); return genericHierarchy(); } } }
public static void main(String argv[]) { if(argv.length == 3) init(argv[0], argv[1], argv[2]); else usage("Wrong number of arguments."); try { cat.info("Listening on port " + port); ServerSocket serverSocket = new ServerSocket(port); while(true) { cat.info("Waiting to accept a new client."); Socket socket = serverSocket.accept(); InetAddress inetAddress = socket.getInetAddress(); cat.info("Connected to client at " + inetAddress); LoggerRepository h = (LoggerRepository) server.hierarchyMap.get(inetAddress); if(h == null) { h = server.configureHierarchy(inetAddress); } cat.info("Starting new socket node."); new Thread(new SocketNode(socket, h)).start(); } } catch(Exception e) { e.printStackTrace(); } }
static void init(String portStr, String configFile, String dirStr) { try { port = Integer.parseInt(portStr); } catch(java.lang.NumberFormatException e) { e.printStackTrace(); usage("Could not interpret port number ["+ portStr +"]."); } PropertyConfigurator.configure(configFile); File dir = new File(dirStr); if(!dir.isDirectory()) { usage("["+dirStr+"] is not a directory."); } server = new SocketServer(dir); }