ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sevdoki...@apache.org
Subject incubator-ignite git commit: # IGNITE-1121 Use java.util.Loggin instead of System.out.*
Date Wed, 22 Jul 2015 14:48:17 GMT
Repository: incubator-ignite
Updated Branches:
  refs/heads/ignite-1121 c025772b1 -> 679e3280a


# IGNITE-1121 Use java.util.Loggin instead of System.out.*


Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/679e3280
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/679e3280
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/679e3280

Branch: refs/heads/ignite-1121
Commit: 679e3280a84dd56a2404a9c78008ab3f173b32a3
Parents: c025772
Author: sevdokimov <sergey.evdokimov@jetbrains.com>
Authored: Wed Jul 22 17:48:04 2015 +0300
Committer: sevdokimov <sergey.evdokimov@jetbrains.com>
Committed: Wed Jul 22 17:48:04 2015 +0300

----------------------------------------------------------------------
 .../org/apache/ignite/agent/AgentLauncher.java    | 16 +++++++++++++++-
 .../java/org/apache/ignite/agent/AgentSocket.java | 18 +++++++++++-------
 .../src/main/resources/logging.properties         |  4 ++++
 3 files changed, 30 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/679e3280/modules/control-center-agent/src/main/java/org/apache/ignite/agent/AgentLauncher.java
----------------------------------------------------------------------
diff --git a/modules/control-center-agent/src/main/java/org/apache/ignite/agent/AgentLauncher.java
b/modules/control-center-agent/src/main/java/org/apache/ignite/agent/AgentLauncher.java
index 47b0187..fabd603 100644
--- a/modules/control-center-agent/src/main/java/org/apache/ignite/agent/AgentLauncher.java
+++ b/modules/control-center-agent/src/main/java/org/apache/ignite/agent/AgentLauncher.java
@@ -23,11 +23,25 @@ import org.eclipse.jetty.websocket.client.*;
 
 import java.io.*;
 import java.net.*;
+import java.util.logging.*;
 
 /**
  *
  */
 public class AgentLauncher {
+    /** Static initializer. */
+    static {
+        try {
+            LogManager.getLogManager().readConfiguration(AgentLauncher.class.getResourceAsStream("/logging.properties"));
+        }
+        catch (IOException e) {
+            throw new RuntimeException(e);
+        }
+    }
+
+    /** */
+    private static final Logger log = Logger.getLogger(AgentLauncher.class.getName());
+
     /** */
     private static final int RECONNECT_INTERVAL = 3000;
 
@@ -91,7 +105,7 @@ public class AgentLauncher {
                 while (true) {
                     AgentSocket agentSock = new AgentSocket(cfg, agent);
 
-                    System.out.printf("Connecting to : %s%n", cfg.getServerUri());
+                    log.log(Level.INFO, "Connecting to: " + cfg.getServerUri());
 
                     client.connect(agentSock, cfg.getServerUri());
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/679e3280/modules/control-center-agent/src/main/java/org/apache/ignite/agent/AgentSocket.java
----------------------------------------------------------------------
diff --git a/modules/control-center-agent/src/main/java/org/apache/ignite/agent/AgentSocket.java
b/modules/control-center-agent/src/main/java/org/apache/ignite/agent/AgentSocket.java
index cee61e4..ec363b4 100644
--- a/modules/control-center-agent/src/main/java/org/apache/ignite/agent/AgentSocket.java
+++ b/modules/control-center-agent/src/main/java/org/apache/ignite/agent/AgentSocket.java
@@ -25,6 +25,7 @@ import org.eclipse.jetty.websocket.api.annotations.*;
 import java.io.*;
 import java.net.*;
 import java.util.concurrent.*;
+import java.util.logging.*;
 
 /**
  *
@@ -32,6 +33,9 @@ import java.util.concurrent.*;
 @WebSocket
 public class AgentSocket {
     /** */
+    private static final Logger log = Logger.getLogger(AgentSocket.class.getName());
+
+    /** */
     private final CountDownLatch closeLatch = new CountDownLatch(1);
 
     /** */
@@ -54,7 +58,7 @@ public class AgentSocket {
      */
     @OnWebSocketClose
     public void onClose(int statusCode, String reason) {
-        System.out.printf("Connection closed: %d - %s%n", statusCode, reason);
+        log.log(Level.INFO, String.format("Connection closed: %d - %s", statusCode, reason));
 
         closeLatch.countDown();
     }
@@ -64,7 +68,7 @@ public class AgentSocket {
      */
     @OnWebSocketConnect
     public void onConnect(Session ses) {
-        System.out.println("Authentication...");
+        log.log(Level.INFO, "Authentication...");
 
         AuthMessage authMsg = new AuthMessage(cfg.getLogin(), cfg.getPassword());
 
@@ -82,9 +86,9 @@ public class AgentSocket {
     @OnWebSocketError
     public void onError(Session ses, Throwable error) {
         if (error instanceof ConnectException)
-            System.out.println(error.getMessage());
+            log.log(Level.INFO, error.getMessage());
         else
-            error.printStackTrace();
+            log.log(Level.SEVERE, "Connection error", error);
 
         closeLatch.countDown();
     }
@@ -98,9 +102,9 @@ public class AgentSocket {
 
         if (m instanceof AuthResult) {
             if (((AuthResult)m).isSuccess())
-                System.out.println("Authentication success");
+                log.info("Authentication success");
             else {
-                System.out.println("Authentication failed: " + ((AuthResult)m).getMessage());
+                log.info("Authentication failed: " + ((AuthResult)m).getMessage());
 
                 ses.close();
             }
@@ -130,7 +134,7 @@ public class AgentSocket {
             }
         }
         else
-            System.err.printf("Unknown message: %s%n", msg);
+            log.log(Level.SEVERE, "Unknown message: " + msg);
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/679e3280/modules/control-center-agent/src/main/resources/logging.properties
----------------------------------------------------------------------
diff --git a/modules/control-center-agent/src/main/resources/logging.properties b/modules/control-center-agent/src/main/resources/logging.properties
new file mode 100644
index 0000000..f63c832
--- /dev/null
+++ b/modules/control-center-agent/src/main/resources/logging.properties
@@ -0,0 +1,4 @@
+handlers =java.util.logging.ConsoleHandler
+.level = INFO
+java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter
+java.util.logging.SimpleFormatter.format=%1$tl:%1$tM:%1$tS %1$Tp %4$s: %5$s%n


Mime
View raw message