Introduce a verbose mode for the Java agent
[deliverable/lttng-ust.git] / liblttng-ust-java-agent / java / lttng-ust-agent-common / org / lttng / ust / agent / client / LttngTcpSessiondClient.java
index 5b5d50c4e3f360b563fb3fd2062934bdb47afac0..6177feac7a849cefb44e959197e30894b295f529 100644 (file)
@@ -32,6 +32,8 @@ import java.nio.ByteOrder;
 import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.TimeUnit;
 
+import org.lttng.ust.agent.utils.LttngUstAgentLogger;
+
 /**
  * Client for agents to connect to a local session daemon, using a TCP socket.
  *
@@ -109,12 +111,14 @@ public class LttngTcpSessiondClient implements Runnable {
                                /*
                                 * Connect to the session daemon before anything else.
                                 */
+                               LttngUstAgentLogger.log(getClass(), "Connecting to sessiond");
                                connectToSessiond();
 
                                /*
                                 * Register to the session daemon as the Java component of the
                                 * UST application.
                                 */
+                               LttngUstAgentLogger.log(getClass(), "Registering to sessiond");
                                registerToSessiond();
 
                                /*
@@ -122,6 +126,7 @@ public class LttngTcpSessiondClient implements Runnable {
                                 * session daemon. This will return if and only if there is a
                                 * fatal error or the socket closes.
                                 */
+                               LttngUstAgentLogger.log(getClass(), "Waiting on sessiond commands...");
                                handleSessiondCmd();
                        } catch (UnknownHostException uhe) {
                                uhe.printStackTrace();
@@ -139,6 +144,7 @@ public class LttngTcpSessiondClient implements Runnable {
         * Dispose this client and close any socket connection it may hold.
         */
        public void close() {
+               LttngUstAgentLogger.log(getClass(), "Closing client");
                this.quit = true;
 
                try {
@@ -247,6 +253,7 @@ public class LttngTcpSessiondClient implements Runnable {
                                 * We don't send any reply to the registration done command.
                                 * This just marks the end of the initial session setup.
                                 */
+                               LttngUstAgentLogger.log(getClass(), "Registration done");
                                continue;
                        }
                        case CMD_LIST:
@@ -254,6 +261,7 @@ public class LttngTcpSessiondClient implements Runnable {
                                SessiondCommand listLoggerCmd = new SessiondListLoggersCommand();
                                LttngAgentResponse response = listLoggerCmd.execute(logAgent);
                                responseData = response.getBytes();
+                               LttngUstAgentLogger.log(getClass(), "Received list loggers command");
                                break;
                        }
                        case CMD_EVENT_ENABLE:
@@ -266,6 +274,7 @@ public class LttngTcpSessiondClient implements Runnable {
                                SessiondCommand enableEventCmd = new SessiondEnableEventCommand(inputData);
                                LttngAgentResponse response = enableEventCmd.execute(logAgent);
                                responseData = response.getBytes();
+                               LttngUstAgentLogger.log(getClass(), "Received enable event command");
                                break;
                        }
                        case CMD_EVENT_DISABLE:
@@ -278,6 +287,7 @@ public class LttngTcpSessiondClient implements Runnable {
                                SessiondCommand disableEventCmd = new SessiondDisableEventCommand(inputData);
                                LttngAgentResponse response = disableEventCmd.execute(logAgent);
                                responseData = response.getBytes();
+                               LttngUstAgentLogger.log(getClass(), "Received disable event command");
                                break;
                        }
                        case CMD_APP_CTX_ENABLE:
@@ -290,6 +300,7 @@ public class LttngTcpSessiondClient implements Runnable {
                                SessiondCommand enableAppCtxCmd = new SessiondEnableAppContextCommand(inputData);
                                LttngAgentResponse response = enableAppCtxCmd.execute(logAgent);
                                responseData = response.getBytes();
+                               LttngUstAgentLogger.log(getClass(), "Received enable app-context command");
                                break;
                        }
                        case CMD_APP_CTX_DISABLE:
@@ -302,6 +313,7 @@ public class LttngTcpSessiondClient implements Runnable {
                                SessiondCommand disableAppCtxCmd = new SessiondDisableAppContextCommand(inputData);
                                LttngAgentResponse response = disableAppCtxCmd.execute(logAgent);
                                responseData = response.getBytes();
+                               LttngUstAgentLogger.log(getClass(), "Received disable app-context command");
                                break;
                        }
                        default:
@@ -310,11 +322,13 @@ public class LttngTcpSessiondClient implements Runnable {
                                responseData = new byte[4];
                                ByteBuffer buf = ByteBuffer.wrap(responseData);
                                buf.order(ByteOrder.BIG_ENDIAN);
+                               LttngUstAgentLogger.log(getClass(), "Received unknown command, ignoring");
                                break;
                        }
                        }
 
                        /* Send response to the session daemon. */
+                       LttngUstAgentLogger.log(getClass(), "Sending response");
                        this.outToSessiond.write(responseData, 0, responseData.length);
                        this.outToSessiond.flush();
                }
This page took 0.024493 seconds and 5 git commands to generate.