Improve logging
authorMathieu Baudier <mbaudier@argeo.org>
Tue, 5 Mar 2024 15:16:26 +0000 (16:16 +0100)
committerMathieu Baudier <mbaudier@argeo.org>
Tue, 5 Mar 2024 15:16:26 +0000 (16:16 +0100)
org.argeo.cms.lib.jetty/src/org/argeo/cms/jetty/JettyHttpServer.java
org.argeo.cms.lib.sshd/src/org/argeo/cms/ssh/CmsSshServer.java

index 74f0aaed3d8ddeb3154585386f15a5968d8c54eb..9d35dadb5d49eabe9464c433f88a8111387eff3e 100644 (file)
@@ -279,7 +279,7 @@ public class JettyHttpServer extends HttpsServer {
                if (httpContext instanceof ContextHandlerHttpContext contextHandlerHttpContext) {
                        // TODO stop handler first?
                        // FIXME understand compatibility with Jetty 12
-                       //contextHandlerCollection.removeHandler(contextHandlerHttpContext.getServletContextHandler());
+                       // contextHandlerCollection.removeHandler(contextHandlerHttpContext.getServletContextHandler());
                } else {
                        // FIXME apparently servlets cannot be removed in Jetty, we should replace the
                        // handler
@@ -315,9 +315,16 @@ public class JettyHttpServer extends HttpsServer {
        }
 
        private String httpPortsMsg() {
+               String hostStr = getHost();
+               hostStr = hostStr == null ? "*:" : hostStr + ":";
+               return (httpConnector != null ? "# HTTP " + hostStr + getHttpPort() + " " : "")
+                               + (httpsConnector != null ? "# HTTPS " + hostStr + getHttpsPort() : "");
+       }
 
-               return (httpConnector != null ? "HTTP " + getHttpPort() + " " : "")
-                               + (httpsConnector != null ? "HTTPS " + getHttpsPort() : "");
+       public String getHost() {
+               if (httpConnector == null)
+                       return null;
+               return httpConnector.getHost();
        }
 
        public Integer getHttpPort() {
index 2480c3df450e1195fce6f7c672a2cc293ef94173..83e7392bca18baff4a50ee0329164fcd0c35ba41 100644 (file)
@@ -172,7 +172,7 @@ public class CmsSshServer implements CmsSshd {
                        // start
                        sshd.start();
 
-                       log.debug(() -> "CMS SSH server started on port " + port + (host != null ? " of host " + host : ""));
+                       log.info("# SSH " + (host != null ? host + ":" : "*:") + port);
                } catch (IOException e) {
                        throw new RuntimeException("Cannot start SSH server on port " + port, e);
                }