From: hyunsik.noh Date: Mon, 21 Jan 2013 07:57:50 +0000 (+0900) Subject: [Title] Fixed to detailed log and to set default log level value X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=50be8c7b53b1466d21e9d4096537f8ac271b80c7;p=sdk%2Fide%2Fcommon-eplugin.git [Title] Fixed to detailed log and to set default log level value [Type] [Module]common [Priority] [CQ#] [Redmine#] [Problem] [Cause] [Solution Change-Id: Id6c74d8fdcbd888a78dea0e3c7e093331f14614a --- diff --git a/org.tizen.common.sdblib/src/org/tizen/sdblib/DeviceMonitor.java b/org.tizen.common.sdblib/src/org/tizen/sdblib/DeviceMonitor.java index 27a3c46..dadc2d4 100644 --- a/org.tizen.common.sdblib/src/org/tizen/sdblib/DeviceMonitor.java +++ b/org.tizen.common.sdblib/src/org/tizen/sdblib/DeviceMonitor.java @@ -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."); } } } diff --git a/org.tizen.common.sdblib/src/org/tizen/sdblib/Log.java b/org.tizen.common.sdblib/src/org/tizen/sdblib/Log.java index 9628a5c..2ab3a19 100644 --- a/org.tizen.common.sdblib/src/org/tizen/sdblib/Log.java +++ b/org.tizen.common.sdblib/src/org/tizen/sdblib/Log.java @@ -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(); diff --git a/org.tizen.common.sdblib/src/org/tizen/sdblib/MultiLineReceiver.java b/org.tizen.common.sdblib/src/org/tizen/sdblib/MultiLineReceiver.java index d8f4999..24a8763 100755 --- a/org.tizen.common.sdblib/src/org/tizen/sdblib/MultiLineReceiver.java +++ b/org.tizen.common.sdblib/src/org/tizen/sdblib/MultiLineReceiver.java @@ -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; } diff --git a/org.tizen.common.sdblib/src/org/tizen/sdblib/SdbPreferences.java b/org.tizen.common.sdblib/src/org/tizen/sdblib/SdbPreferences.java index 4e4d326..50582ff 100644 --- a/org.tizen.common.sdblib/src/org/tizen/sdblib/SdbPreferences.java +++ b/org.tizen.common.sdblib/src/org/tizen/sdblib/SdbPreferences.java @@ -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; } diff --git a/org.tizen.common.sdblib/src/org/tizen/sdblib/SmartDevelopmentBridge.java b/org.tizen.common.sdblib/src/org/tizen/sdblib/SmartDevelopmentBridge.java index 5d8698d..e5a8030 100644 --- a/org.tizen.common.sdblib/src/org/tizen/sdblib/SmartDevelopmentBridge.java +++ b/org.tizen.common.sdblib/src/org/tizen/sdblib/SmartDevelopmentBridge.java @@ -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; }