[Title] Fixed to detailed log and to set default log level value
authorhyunsik.noh <hyunsik.noh@samsung.com>
Mon, 21 Jan 2013 07:57:50 +0000 (16:57 +0900)
committerhyunsik.noh <hyunsik.noh@samsung.com>
Mon, 21 Jan 2013 07:57:50 +0000 (16:57 +0900)
[Type]
[Module]common
[Priority]
[CQ#]
[Redmine#]
[Problem]
[Cause]
[Solution

Change-Id: Id6c74d8fdcbd888a78dea0e3c7e093331f14614a

org.tizen.common.sdblib/src/org/tizen/sdblib/DeviceMonitor.java
org.tizen.common.sdblib/src/org/tizen/sdblib/Log.java
org.tizen.common.sdblib/src/org/tizen/sdblib/MultiLineReceiver.java
org.tizen.common.sdblib/src/org/tizen/sdblib/SdbPreferences.java
org.tizen.common.sdblib/src/org/tizen/sdblib/SmartDevelopmentBridge.java

index 27a3c46..dadc2d4 100644 (file)
@@ -62,6 +62,7 @@ final class DeviceMonitor {
      * Starts the monitoring.
      */
     void start() {
+        Log.d("DeviceMonitor", "start monitoring");
         new Thread("Device List Monitor") { //$NON-NLS-1$
             @Override
             public void run() {
@@ -74,6 +75,7 @@ final class DeviceMonitor {
      * Stops the monitoring.
      */
     void stop() {
+        Log.d("DeviceMonitor", "stop monitoring");
         mQuit = true;
 
         // wake up the main loop thread by closing the main connection to sdb.
@@ -133,9 +135,10 @@ final class DeviceMonitor {
         do {
             try {
                 if (mMainSdbConnection == null) {
-                    Log.d("DeviceMonitor", "Opening sdb connection");
+                    Log.d("DeviceMonitor", "opening sdb connection");
                     mMainSdbConnection = openSdbConnection();
                     if (mMainSdbConnection == null) {
+                        Log.d("DeviceMonitor", "start sdb");
                         if (mServer.startSdb() == false) {
                             mRestartAttemptCount++;
                             Log.e("DeviceMonitor",
@@ -143,7 +146,7 @@ final class DeviceMonitor {
                         }
                         waitABit();
                     } else {
-                        Log.d("DeviceMonitor", "Connected to sdb for device monitoring");
+                        Log.d("DeviceMonitor", "connected to sdb for device monitoring");
                     }
                 }
 
@@ -176,9 +179,9 @@ final class DeviceMonitor {
     private void handleExpectioninMonitorLoop(Exception e) {
         if (mQuit == false) {
             if (e instanceof TimeoutException) {
-                Log.e("DeviceMonitor", "Sdb connection Error: timeout");
+                Log.e("DeviceMonitor", "sdb connection Error: timeout");
             } else {
-                Log.e("DeviceMonitor", "Sdb connection Error:" + e.getMessage());
+                Log.e("DeviceMonitor", "sdb connection Error:" + e.getMessage());
             }
             mMonitoring = false;
             if (mMainSdbConnection != null) {
@@ -208,7 +211,7 @@ final class DeviceMonitor {
      * @return a connect socket if success, null otherwise
      */
     private SocketChannel openSdbConnection() {
-        Log.d("DeviceMonitor", "Connecting to sdb for Device List Monitoring...");
+        Log.d("DeviceMonitor", "connecting to sdb for Device List Monitoring...");
 
         SocketChannel sdbChannel = null;
         try {
@@ -228,7 +231,7 @@ final class DeviceMonitor {
      */
     private boolean sendDeviceListMonitoringRequest() throws TimeoutException, IOException {
         byte[] request = SdbHelper.formSdbRequest("host:track-devices"); //$NON-NLS-1$
-
+        Log.d("DeviceMonitor", "send monitoring request");
         try {
             SdbHelper.write(mMainSdbConnection, request);
 
@@ -242,7 +245,7 @@ final class DeviceMonitor {
 
             return resp.okay;
         } catch (IOException e) {
-            Log.e("DeviceMonitor", "Sending Tracking request failed!");
+            Log.e("DeviceMonitor", "sending tracking request failed!");
             mMainSdbConnection.close();
             throw e;
         }
@@ -264,6 +267,7 @@ final class DeviceMonitor {
             String[] devices = result.split("\n"); // $NON-NLS-1$
 
             for (String d : devices) {
+                Log.d("DeviceMonitor", "deviceData: " + d);
                 String[] param = d.split("\t"); // $NON-NLS-1$
                 if (param.length == 3) {
                     // new sdb uses only serial numbers to identify devices
@@ -273,6 +277,7 @@ final class DeviceMonitor {
 
                     //add the device to the list
                     list.add(device);
+                    Log.d("DeviceMonitor", "deviceData: " + device.getSerialNumber() + " added to list");
                 }
             }
         }
@@ -321,6 +326,7 @@ final class DeviceMonitor {
                                 {
                                     device.checkArchitecture();
                                     device.checkDeviceType();
+                                    Log.d("DeviceMonitor", "updateDevices: " + device.getSerialNumber() + " onlined");
                                 }
                                 device.update(Device.CHANGE_STATE);
                             }
@@ -335,6 +341,7 @@ final class DeviceMonitor {
                         // to process the next one.
                         removeDevice(device);
                         mServer.deviceDisconnected(device);
+                        Log.d("DeviceMonitor", "updateDevices: " + device.getSerialNumber() + " off-lined");
                     } else {
                         // process the next one
                         d++;
@@ -357,6 +364,7 @@ final class DeviceMonitor {
                     if (newDevice.isOnline()) {
                         devicesToQuery.add(newDevice);
                         mServer.deviceConnected(newDevice);
+                        Log.d("DeviceMonitor", "updateDevices: " + newDevice.getSerialNumber() + " newly connected.");
                     }
                 }
             }
index 9628a5c..2ab3a19 100644 (file)
@@ -364,12 +364,13 @@ public final class Log {
         File file = new File(home_path);
         if(home_path != null && file.exists() && file.isDirectory())
         {
-            String fileName = home_path + File.separatorChar + formatter.format(new Date()) + "_sdblib_log";
+            String fileName = home_path + File.separatorChar + "tizen-sdk-data" + 
+                    File.separatorChar + formatter.format(new Date()) + "_sdblib_log";
             FileWriter writer = null;
 
             try
             {
-                writer = new FileWriter(fileName, true);
+                writer = new FileWriter(fileName, false);
                 writer.write(msg);
                 writer.write('\n');
                 writer.flush();
index d8f4999..24a8763 100755 (executable)
@@ -108,6 +108,10 @@ public abstract class MultiLineReceiver implements IShellOutputReceiver {
                                }
                        }
                }
+               else
+               {
+                   Log.d("sdb", "process cancelled");
+               }
        }
 
        /*
@@ -137,7 +141,6 @@ public abstract class MultiLineReceiver implements IShellOutputReceiver {
         * @see com.samsung.sdblib.sdb.IShellOutputReceiver#isCancelled()
         */
        public boolean isCancelled() {
-               Log.d("sdb", "process cancelled");
                return false;
        }
 
index 4e4d326..50582ff 100644 (file)
@@ -30,7 +30,7 @@ import org.tizen.sdblib.Log.LogLevel;
  */
 public final class SdbPreferences {
 
-       public final static LogLevel DEFAULT_LOG_LEVEL = LogLevel.ERROR;
+       public static LogLevel DEFAULT_LOG_LEVEL = LogLevel.ERROR;
     /** Default timeout values for sdb connection (milliseconds) */
     public static final int DEFAULT_TIMEOUT = 5000; // standard delay, in ms
 
@@ -41,6 +41,19 @@ public final class SdbPreferences {
      * Returns the minimum {@link LogLevel} being displayed.
      */
     public static LogLevel getLogLevel() {
+        String default_level = System.getProperty("default.sdblib.loglevel");
+        if(default_level != null)
+        {
+            LogLevel levels[] = LogLevel.values();
+            for(LogLevel level : levels)
+            {
+                if(level.getPriority() == Integer.parseInt(default_level))
+                {
+                    DEFAULT_LOG_LEVEL = level;
+                    return DEFAULT_LOG_LEVEL;
+                }
+            }
+        }
         return sLogLevel;
     }
 
index 5d8698d..e5a8030 100644 (file)
@@ -652,7 +652,7 @@ public final class SmartDevelopmentBridge {
             command[0] = mSdbOsLocation;
             command[1] = "start-server"; //$NON-NLS-1$
             Log.d(SDBLIB,
-                    String.format("Launching '%1$s %2$s' to ensure SDB is running.", //$NON-NLS-1$
+                    String.format("launching '%1$s %2$s' to ensure SDB is running.", //$NON-NLS-1$
                     mSdbOsLocation, command[1]));
             proc = Runtime.getRuntime().exec(command);
 
@@ -662,10 +662,10 @@ public final class SmartDevelopmentBridge {
                     false /* waitForReaders */);
 
         } catch (IOException ioe) {
-            Log.d(SDBLIB, "Unable to run 'sdb': " + ioe.getMessage()); //$NON-NLS-1$
+            Log.d(SDBLIB, "unable to run 'sdb': " + ioe.getMessage()); //$NON-NLS-1$
             // we'll return false;
         } catch (InterruptedException ie) {
-            Log.d(SDBLIB, "Unable to run 'sdb': " + ie.getMessage()); //$NON-NLS-1$
+            Log.d(SDBLIB, "unable to run 'sdb': " + ie.getMessage()); //$NON-NLS-1$
             // we'll return false;
         }