Commit c0c530835705fdba1cd8a1b01e5bbde96951889e

Authored by 杜方
1 parent d77aad46

畅游通核销app: 1.增加本地写入日志

.gitignore
1 -/CYTAndroid4.0.iml  
2 -build.gradle  
3 -local.properties  
4 -license.dat  
5 -proguard-project.txt  
6 -local.properties  
7 -gradle  
8 -.gradle  
9 -.idea  
10 -*.iml  
11 -.project  
12 -gradlew  
13 -gradlew.bat  
14 -.gitignore  
15 -build  
16 -.settings  
17 -project.properties  
18 -/release/ 1 +#/CYTAndroid4.0.iml
  2 +#build.gradle
  3 +#local.properties
  4 +#license.dat
  5 +#proguard-project.txt
  6 +#local.properties
  7 +#gradle
  8 +#.gradle
  9 +#.idea
  10 +#*.iml
  11 +#.project
  12 +#gradlew
  13 +#gradlew.bat
  14 +#.gitignore
  15 +#build
  16 +#.settings
  17 +#project.properties
  18 +#/release/
  19 +/build
CYTAndroid4.0.iml
@@ -98,6 +98,8 @@ @@ -98,6 +98,8 @@
98 <orderEntry type="library" name="Gradle: ./libs/zxing.jar" level="project" /> 98 <orderEntry type="library" name="Gradle: ./libs/zxing.jar" level="project" />
99 <orderEntry type="library" name="Gradle: ./libs/gson-2.6.2.jar" level="project" /> 99 <orderEntry type="library" name="Gradle: ./libs/gson-2.6.2.jar" level="project" />
100 <orderEntry type="library" name="Gradle: ./libs/zypos1.8.jar" level="project" /> 100 <orderEntry type="library" name="Gradle: ./libs/zypos1.8.jar" level="project" />
  101 + <orderEntry type="library" name="Gradle: ./libs/android-logging-log4j-1.0.3.jar" level="project" />
  102 + <orderEntry type="library" name="Gradle: ./libs/log4j-1.2.17.jar" level="project" />
101 <orderEntry type="library" name="Gradle: ./libs/bw_pos_sdk2.0.18.jar" level="project" /> 103 <orderEntry type="library" name="Gradle: ./libs/bw_pos_sdk2.0.18.jar" level="project" />
102 </component> 104 </component>
103 </module> 105 </module>
104 \ No newline at end of file 106 \ No newline at end of file
build.gradle
@@ -31,6 +31,8 @@ dependencies { @@ -31,6 +31,8 @@ dependencies {
31 implementation files('libs/zxing.jar') 31 implementation files('libs/zxing.jar')
32 implementation files('libs/gson-2.6.2.jar') 32 implementation files('libs/gson-2.6.2.jar')
33 implementation files('libs\\zypos1.8.jar') 33 implementation files('libs\\zypos1.8.jar')
  34 + implementation files('libs\\android-logging-log4j-1.0.3.jar')
  35 + implementation files('libs\\log4j-1.2.17.jar')
34 compileOnly files('external_libs/classes_2.1.11_20160907.jar') 36 compileOnly files('external_libs/classes_2.1.11_20160907.jar')
35 compileOnly files('external_libs/bw_odm_20160526.jar') 37 compileOnly files('external_libs/bw_odm_20160526.jar')
36 implementation files('libs/bw_pos_sdk2.0.18.jar') 38 implementation files('libs/bw_pos_sdk2.0.18.jar')
src/android_serialport_api/print_tool/MobilePrintTool.java
@@ -216,7 +216,7 @@ public class MobilePrintTool extends Activity { @@ -216,7 +216,7 @@ public class MobilePrintTool extends Activity {
216 if (address == null) { 216 if (address == null) {
217 break; 217 break;
218 } 218 }
219 - LogUtil.i("address" + address); 219 + LogUtil.i(TAG,"address" + address);
220 // 获取设备进行连接 220 // 获取设备进行连接
221 BluetoothDevice device = mBluetoothAdapter 221 BluetoothDevice device = mBluetoothAdapter
222 .getRemoteDevice(address); 222 .getRemoteDevice(address);
@@ -274,7 +274,7 @@ public class MobilePrintTool extends Activity { @@ -274,7 +274,7 @@ public class MobilePrintTool extends Activity {
274 printer = new PrinterEscCmd(); 274 printer = new PrinterEscCmd();
275 } 275 }
276 final int printNum = MyApp.getInstance().getPrintNum(); 276 final int printNum = MyApp.getInstance().getPrintNum();
277 - LogUtil.d(printNum + getString(R.string.times)); 277 + LogUtil.d(TAG,printNum + getString(R.string.times));
278 new Thread(new Runnable() { 278 new Thread(new Runnable() {
279 @Override 279 @Override
280 public void run() { 280 public void run() {
src/com/ectrip/cyt/config/MyApp.java
@@ -529,7 +529,7 @@ public class MyApp extends BaseApplication { @@ -529,7 +529,7 @@ public class MyApp extends BaseApplication {
529 intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); 529 intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
530 startActivity(intent); 530 startActivity(intent);
531 } catch (Exception e) { 531 } catch (Exception e) {
532 - LogUtil.v(TAG, 532 + LogUtil.i(TAG,
533 "open network settings failed, please check..."); 533 "open network settings failed, please check...");
534 e.printStackTrace(); 534 e.printStackTrace();
535 } 535 }
src/com/ectrip/cyt/exceptionsave/debug/LocalLogRunnable.java
@@ -8,6 +8,7 @@ import java.util.Calendar; @@ -8,6 +8,7 @@ import java.util.Calendar;
8 import java.util.Date; 8 import java.util.Date;
9 9
10 import com.ectrip.cyt.exceptionsave.init.InitAppValue; 10 import com.ectrip.cyt.exceptionsave.init.InitAppValue;
  11 +import com.ectrip.cyt.utils.LogUtil;
11 12
12 import android.content.Context; 13 import android.content.Context;
13 import android.content.Intent; 14 import android.content.Intent;
@@ -19,7 +20,7 @@ import android.util.Log; @@ -19,7 +20,7 @@ import android.util.Log;
19 20
20 public class LocalLogRunnable implements Runnable{ 21 public class LocalLogRunnable implements Runnable{
21 22
22 - private String TAG="LocalLogRunnable"; 23 + private static final String TAG="LocalLogRunnable";
23 24
24 private Context mContext; 25 private Context mContext;
25 private Throwable ex; 26 private Throwable ex;
@@ -174,6 +175,7 @@ public class LocalLogRunnable implements Runnable{ @@ -174,6 +175,7 @@ public class LocalLogRunnable implements Runnable{
174 randomFile.close(); 175 randomFile.close();
175 } catch (IOException e) { 176 } catch (IOException e) {
176 e.printStackTrace(); 177 e.printStackTrace();
  178 + LogUtil.d(TAG, LogUtil.getExMsg(e));
177 } 179 }
178 } 180 }
179 } 181 }
src/com/ectrip/cyt/ui/BaseActivity.java
@@ -231,7 +231,7 @@ public abstract class BaseActivity extends FragmentActivity { @@ -231,7 +231,7 @@ public abstract class BaseActivity extends FragmentActivity {
231 } 231 }
232 isPause.set(true); 232 isPause.set(true);
233 super.onBackPressed(); 233 super.onBackPressed();
234 - LogUtil.i(getString(R.string.back_pressed)); 234 + LogUtil.i(TAG,getString(R.string.back_pressed));
235 if (netDialog != null && netDialog.isShowing()) { 235 if (netDialog != null && netDialog.isShowing()) {
236 try { 236 try {
237 netDialog.dismiss(); 237 netDialog.dismiss();
src/com/ectrip/cyt/ui/MainActivity.java
@@ -157,14 +157,14 @@ public class MainActivity extends BaseActivity implements OnItemClickListener, V @@ -157,14 +157,14 @@ public class MainActivity extends BaseActivity implements OnItemClickListener, V
157 && getSerialNumber().contains("CTY") && getSerialNumber() 157 && getSerialNumber().contains("CTY") && getSerialNumber()
158 .substring(0, 3).equals("CTY"))) { 158 .substring(0, 3).equals("CTY"))) {
159 // 新的pos机 159 // 新的pos机
160 - LogUtil.i(getString(R.string.new_pos)); 160 + LogUtil.i(TAG,getString(R.string.new_pos));
161 SharedPreferences2Obj.getInstance(MainActivity.this) 161 SharedPreferences2Obj.getInstance(MainActivity.this)
162 .setName("MachineType") 162 .setName("MachineType")
163 .setObject("type", DeviceType.New_POS.getValue()); 163 .setObject("type", DeviceType.New_POS.getValue());
164 } else if (DevicTool.getInstance().isHiboryPos()) { 164 } else if (DevicTool.getInstance().isHiboryPos()) {
165 LogUtil.d(TAG, "5501H手持机"); 165 LogUtil.d(TAG, "5501H手持机");
166 // 5501H手持机 166 // 5501H手持机
167 - LogUtil.i(getString(R.string.handset)); 167 + LogUtil.i(TAG,getString(R.string.handset));
168 SharedPreferences2Obj.getInstance(MainActivity.this) 168 SharedPreferences2Obj.getInstance(MainActivity.this)
169 .setName("MachineType") 169 .setName("MachineType")
170 .setObject("type", DeviceType.BLACK_ID_POS.getValue()); 170 .setObject("type", DeviceType.BLACK_ID_POS.getValue());
@@ -173,7 +173,7 @@ public class MainActivity extends BaseActivity implements OnItemClickListener, V @@ -173,7 +173,7 @@ public class MainActivity extends BaseActivity implements OnItemClickListener, V
173 .substring(0, 2).equals("LY"))) { 173 .substring(0, 2).equals("LY"))) {
174 release(); 174 release();
175 // 新的手持pos机 175 // 新的手持pos机
176 - LogUtil.i(getString(R.string.new_handset_pos)); 176 + LogUtil.i(TAG,getString(R.string.new_handset_pos));
177 SharedPreferences2Obj 177 SharedPreferences2Obj
178 .getInstance(MainActivity.this) 178 .getInstance(MainActivity.this)
179 .setName("MachineType") 179 .setName("MachineType")
@@ -183,13 +183,13 @@ public class MainActivity extends BaseActivity implements OnItemClickListener, V @@ -183,13 +183,13 @@ public class MainActivity extends BaseActivity implements OnItemClickListener, V
183 && getSerialNumber().contains("DY") && getSerialNumber() 183 && getSerialNumber().contains("DY") && getSerialNumber()
184 .substring(0, 2).equals("DY"))) { 184 .substring(0, 2).equals("DY"))) {
185 // 新的身份证pos机 185 // 新的身份证pos机
186 - LogUtil.i(getString(R.string.new_id_pos)); 186 + LogUtil.i(TAG,getString(R.string.new_id_pos));
187 SharedPreferences2Obj.getInstance(MainActivity.this) 187 SharedPreferences2Obj.getInstance(MainActivity.this)
188 .setName("MachineType") 188 .setName("MachineType")
189 .setObject("type", DeviceType.New_IDPOS.getValue()); 189 .setObject("type", DeviceType.New_IDPOS.getValue());
190 } else if (HdxUtil.SetIDCARDPower(1) != -1) { 190 } else if (HdxUtil.SetIDCARDPower(1) != -1) {
191 // 身份证pos机 191 // 身份证pos机
192 - LogUtil.i(getString(R.string.id_pos)); 192 + LogUtil.i(TAG,getString(R.string.id_pos));
193 SharedPreferences2Obj.getInstance(MainActivity.this) 193 SharedPreferences2Obj.getInstance(MainActivity.this)
194 .setName("MachineType") 194 .setName("MachineType")
195 .setObject("type", DeviceType.ID_POS.getValue()); 195 .setObject("type", DeviceType.ID_POS.getValue());
@@ -197,7 +197,7 @@ public class MainActivity extends BaseActivity implements OnItemClickListener, V @@ -197,7 +197,7 @@ public class MainActivity extends BaseActivity implements OnItemClickListener, V
197 || DevicTool.getInstance().isSerialPortHandset()) { 197 || DevicTool.getInstance().isSerialPortHandset()) {
198 release(); 198 release();
199 // 黄色手持机 199 // 黄色手持机
200 - LogUtil.i(getString(R.string.handset)); 200 + LogUtil.i(TAG,getString(R.string.handset));
201 SharedPreferences2Obj.getInstance(MainActivity.this) 201 SharedPreferences2Obj.getInstance(MainActivity.this)
202 .setName("MachineType") 202 .setName("MachineType")
203 .setObject("type", DeviceType.HANDSET.getValue()); 203 .setObject("type", DeviceType.HANDSET.getValue());
@@ -207,14 +207,14 @@ public class MainActivity extends BaseActivity implements OnItemClickListener, V @@ -207,14 +207,14 @@ public class MainActivity extends BaseActivity implements OnItemClickListener, V
207 && height <= 500) { 207 && height <= 500) {
208 release(); 208 release();
209 // 小pos机 209 // 小pos机
210 - LogUtil.i(getString(R.string.small_pos)); 210 + LogUtil.i(TAG,getString(R.string.small_pos));
211 SharedPreferences2Obj.getInstance(MainActivity.this) 211 SharedPreferences2Obj.getInstance(MainActivity.this)
212 .setName("MachineType") 212 .setName("MachineType")
213 .setObject("type", DeviceType.SMALL_POS.getValue()); 213 .setObject("type", DeviceType.SMALL_POS.getValue());
214 } else if (DevicTool.getInstance().isSerialPort() 214 } else if (DevicTool.getInstance().isSerialPort()
215 || DevicTool.getInstance().isIdPosPrint()) { 215 || DevicTool.getInstance().isIdPosPrint()) {
216 // 一般pos机 216 // 一般pos机
217 - LogUtil.i(getString(R.string.general_pos)); 217 + LogUtil.i(TAG,getString(R.string.general_pos));
218 SharedPreferences2Obj.getInstance(MainActivity.this) 218 SharedPreferences2Obj.getInstance(MainActivity.this)
219 .setName("MachineType") 219 .setName("MachineType")
220 .setObject("type", DeviceType.GENERAL_POS.getValue()); 220 .setObject("type", DeviceType.GENERAL_POS.getValue());
@@ -222,7 +222,7 @@ public class MainActivity extends BaseActivity implements OnItemClickListener, V @@ -222,7 +222,7 @@ public class MainActivity extends BaseActivity implements OnItemClickListener, V
222 //盛本pos机测试******************************* 222 //盛本pos机测试*******************************
223 else if (BindService.getInstance().isBasewin()) { 223 else if (BindService.getInstance().isBasewin()) {
224 // 盛本pos机 224 // 盛本pos机
225 - LogUtil.i("盛本POS机"); 225 + LogUtil.i(TAG,"盛本POS机");
226 SharedPreferences2Obj.getInstance(MainActivity.this) 226 SharedPreferences2Obj.getInstance(MainActivity.this)
227 .setName("MachineType") 227 .setName("MachineType")
228 .setObject("type", DeviceType.BASEWIN_REB_POS.getValue()); 228 .setObject("type", DeviceType.BASEWIN_REB_POS.getValue());
@@ -231,7 +231,7 @@ public class MainActivity extends BaseActivity implements OnItemClickListener, V @@ -231,7 +231,7 @@ public class MainActivity extends BaseActivity implements OnItemClickListener, V
231 else { 231 else {
232 release(); 232 release();
233 // 手机 233 // 手机
234 - LogUtil.i(getString(R.string.mobile)); 234 + LogUtil.i(TAG,getString(R.string.mobile));
235 SharedPreferences2Obj.getInstance(MainActivity.this) 235 SharedPreferences2Obj.getInstance(MainActivity.this)
236 .setName("MachineType") 236 .setName("MachineType")
237 .setObject("type", DeviceType.MOBILE.getValue()); 237 .setObject("type", DeviceType.MOBILE.getValue());
src/com/ectrip/cyt/ui/NewHandleScanerActivity.java
@@ -159,7 +159,7 @@ public class NewHandleScanerActivity extends BaseActivity { @@ -159,7 +159,7 @@ public class NewHandleScanerActivity extends BaseActivity {
159 } else { 159 } else {
160 try { 160 try {
161 if (result.startsWith("CYT_")) { 161 if (result.startsWith("CYT_")) {
162 - LogUtil.i("result = " + result); 162 + LogUtil.i(TAG,"result = " + result);
163 typeScan = 0; 163 typeScan = 0;
164 if (result.contains(",")) { 164 if (result.contains(",")) {
165 result = result.substring(result.indexOf("_") + 1, result.indexOf(",")); 165 result = result.substring(result.indexOf("_") + 1, result.indexOf(","));
src/com/ectrip/cyt/ui/PhomeScanerOrderActivity.java
@@ -177,7 +177,7 @@ public class PhomeScanerOrderActivity extends BaseActivity implements Callback { @@ -177,7 +177,7 @@ public class PhomeScanerOrderActivity extends BaseActivity implements Callback {
177 QRCodeOrderListActivity.class); 177 QRCodeOrderListActivity.class);
178 intent.putExtra("mode", 1); 178 intent.putExtra("mode", 1);
179 intent.putExtra("input_orid", resultString); 179 intent.putExtra("input_orid", resultString);
180 - LogUtil.i(getString(R.string.scan_result) + resultString); 180 + LogUtil.i(TAG,getString(R.string.scan_result) + resultString);
181 intent.putExtra("titleName", getString(R.string.show_result)); 181 intent.putExtra("titleName", getString(R.string.show_result));
182 intent.putExtra("typeScan", typeScan); 182 intent.putExtra("typeScan", typeScan);
183 startActivity(intent); 183 startActivity(intent);
src/com/ectrip/cyt/ui/ScanerHandsetActivity.java
@@ -189,7 +189,7 @@ public class ScanerHandsetActivity extends SerialPortHandsetActivity { @@ -189,7 +189,7 @@ public class ScanerHandsetActivity extends SerialPortHandsetActivity {
189 QRCodeOrderListActivity.class); 189 QRCodeOrderListActivity.class);
190 intent.putExtra("mode", 1); 190 intent.putExtra("mode", 1);
191 intent.putExtra("input_orid", resultString); 191 intent.putExtra("input_orid", resultString);
192 - LogUtil.i("scan_result:" + resultString); 192 + LogUtil.i(TAG,"scan_result:" + resultString);
193 intent.putExtra("titleName", 193 intent.putExtra("titleName",
194 getString(R.string.show_result)); 194 getString(R.string.show_result));
195 startActivity(intent); 195 startActivity(intent);
src/com/ectrip/cyt/ui/ScanerIdCardActivity.java
@@ -142,10 +142,10 @@ public class ScanerIdCardActivity extends BaseActivity { @@ -142,10 +142,10 @@ public class ScanerIdCardActivity extends BaseActivity {
142 public void readIdCard(int num) throws Throwable { 142 public void readIdCard(int num) throws Throwable {
143 if (idcread.Authenticate() == 1 && !isStop.get())/* 身份证认证 */ 143 if (idcread.Authenticate() == 1 && !isStop.get())/* 身份证认证 */
144 { 144 {
145 - LogUtil.d(getString(R.string.id_auth_success)); 145 + LogUtil.d(TAG,getString(R.string.id_auth_success));
146 if (idcread.ReadContent("/mnt/sdcard/") == 1)/* 读取身份证数据 */// 146 if (idcread.ReadContent("/mnt/sdcard/") == 1)/* 读取身份证数据 *///
147 { 147 {
148 - LogUtil.d(getString(R.string.read_id_info_success)); 148 + LogUtil.d(TAG,getString(R.string.read_id_info_success));
149 try { 149 try {
150 testRead(); 150 testRead();
151 } catch (Exception e) { 151 } catch (Exception e) {
@@ -170,7 +170,7 @@ public class ScanerIdCardActivity extends BaseActivity { @@ -170,7 +170,7 @@ public class ScanerIdCardActivity extends BaseActivity {
170 e.printStackTrace(); 170 e.printStackTrace();
171 } 171 }
172 } 172 }
173 - LogUtil.d(getString(R.string.read_id_info_fail)); 173 + LogUtil.d(TAG,getString(R.string.read_id_info_fail));
174 MToast(ScanerIdCardActivity.this, 174 MToast(ScanerIdCardActivity.this,
175 getString(R.string.read_id_info_fail), 175 getString(R.string.read_id_info_fail),
176 MToast.LENGTH_SHORT); 176 MToast.LENGTH_SHORT);
@@ -191,7 +191,7 @@ public class ScanerIdCardActivity extends BaseActivity { @@ -191,7 +191,7 @@ public class ScanerIdCardActivity extends BaseActivity {
191 } 191 }
192 } 192 }
193 num = 0; 193 num = 0;
194 - LogUtil.d(getString(R.string.id_auth_fail)); 194 + LogUtil.d(TAG,getString(R.string.id_auth_fail));
195 MToast(ScanerIdCardActivity.this, 195 MToast(ScanerIdCardActivity.this,
196 getString(R.string.id_stick_to_the_back), 196 getString(R.string.id_stick_to_the_back),
197 MToast.LENGTH_SHORT); 197 MToast.LENGTH_SHORT);
src/com/ectrip/cyt/ui/SettingsActivity.java
@@ -635,14 +635,14 @@ public class SettingsActivity extends BaseActivity implements OnClickListener, @@ -635,14 +635,14 @@ public class SettingsActivity extends BaseActivity implements OnClickListener,
635 if (!ec_name.equals("")) { 635 if (!ec_name.equals("")) {
636 try { 636 try {
637 ec_name = AESEncryptor.decrypt(constant.decrypt, ec_name); 637 ec_name = AESEncryptor.decrypt(constant.decrypt, ec_name);
638 - LogUtil.d(getString(R.string.enterprise_communication_identifier) 638 + LogUtil.d(TAG,getString(R.string.enterprise_communication_identifier)
639 + ec_name); 639 + ec_name);
640 ec_name = AESEncryptor.encrypt(constant.decrypt, ec_name); 640 ec_name = AESEncryptor.encrypt(constant.decrypt, ec_name);
641 } catch (Exception ex) { 641 } catch (Exception ex) {
642 try { 642 try {
643 ec_name = AESEncryptor.encrypt(constant.decrypt, 643 ec_name = AESEncryptor.encrypt(constant.decrypt,
644 ec_name); 644 ec_name);
645 - LogUtil.d(getString(R.string.not_successfully_decrypt) 645 + LogUtil.d(TAG,getString(R.string.not_successfully_decrypt)
646 + ec_name); 646 + ec_name);
647 } catch (Exception e) { 647 } catch (Exception e) {
648 e.printStackTrace(); 648 e.printStackTrace();
src/com/ectrip/cyt/utils/LogUtil.java
1 package com.ectrip.cyt.utils; 1 package com.ectrip.cyt.utils;
2 2
  3 +import android.text.TextUtils;
3 import android.util.Log; 4 import android.util.Log;
4 5
  6 +import com.ectrip.cyt.exceptionsave.debug.ConfigureLog4J;
  7 +
  8 +import org.apache.log4j.Logger;
  9 +
  10 +import java.io.ByteArrayOutputStream;
  11 +import java.io.PrintStream;
  12 +
5 /** 13 /**
6 * Log统一管理类 14 * Log统一管理类
7 */ 15 */
@@ -9,106 +17,85 @@ public class LogUtil @@ -9,106 +17,85 @@ public class LogUtil
9 { 17 {
10 public static boolean isDebug = true;// 是否需要打印bug,可以在application的onCreate函数里面初始化 18 public static boolean isDebug = true;// 是否需要打印bug,可以在application的onCreate函数里面初始化
11 private static final String TAG = "MyAndroid"; 19 private static final String TAG = "MyAndroid";
12 - 20 + private static boolean isConfigured = false;
13 // 下面四个是默认tag的函数 21 // 下面四个是默认tag的函数
14 - public static void i(String msg)  
15 - {  
16 - if (isDebug)  
17 - try {  
18 - Log.i(TAG, msg);  
19 - } catch (Exception e) {  
20 - e.printStackTrace();  
21 - } 22 + public static void d(String tag, String message) {
  23 + if (isDebug) {
  24 + Logger LOGGER = getLogger(tag);
  25 + LOGGER.debug(message);
  26 + }
22 } 27 }
23 28
24 - public static void d(String msg)  
25 - {  
26 - if (isDebug)  
27 - try {  
28 - Log.d(TAG, msg);  
29 - } catch (Exception e) {  
30 - e.printStackTrace();  
31 - } 29 + public static void d(String tag, String message, Throwable exception) {
  30 + if (isDebug) {
  31 + Logger LOGGER = getLogger(tag);
  32 + LOGGER.debug(message, exception);
  33 + }
32 } 34 }
33 35
34 - public static void w(String msg)  
35 - {  
36 - if (isDebug)  
37 - try {  
38 - Log.w(TAG, msg);  
39 - } catch (Exception e) {  
40 - e.printStackTrace();  
41 - } 36 + public static void i(String tag, String message) {
  37 + if (isDebug) {
  38 + Logger LOGGER = getLogger(tag);
  39 + LOGGER.info(message);
  40 + }
42 } 41 }
43 42
44 - public static void e(String msg)  
45 - {  
46 - if (isDebug)  
47 - try {  
48 - Log.e(TAG, msg);  
49 - } catch (Exception e1) {  
50 - e1.printStackTrace();  
51 - } 43 + public static void i(String tag, String message, Throwable exception) {
  44 + if (isDebug) {
  45 + Logger LOGGER = getLogger(tag);
  46 + LOGGER.info(message, exception);
  47 + }
52 } 48 }
53 49
54 - public static void v(String msg)  
55 - {  
56 - if (isDebug)  
57 - try {  
58 - Log.v(TAG, msg);  
59 - } catch (Exception e) {  
60 - e.printStackTrace();  
61 - } 50 + public static void w(String tag, String message) {
  51 + if (isDebug) {
  52 + Logger LOGGER = getLogger(tag);
  53 + LOGGER.warn(message);
  54 + }
62 } 55 }
63 56
64 - // 下面是传入自定义tag的函数  
65 - public static void i(String tag, String msg)  
66 - {  
67 - if (isDebug)  
68 - try {  
69 - Log.i(tag, msg);  
70 - } catch (Exception e) {  
71 - e.printStackTrace();  
72 - } 57 + public static void w(String tag, String message, Throwable exception) {
  58 + if (isDebug) {
  59 + Logger LOGGER = getLogger(tag);
  60 + LOGGER.warn(message, exception);
  61 + }
73 } 62 }
74 63
75 - public static void d(String tag, String msg)  
76 - {  
77 - if (isDebug)  
78 - try {  
79 - Log.d(tag, msg);  
80 - } catch (Exception e) {  
81 - e.printStackTrace();  
82 - } 64 + public static void e(String tag, String message) {
  65 + if (isDebug) {
  66 + Logger LOGGER = getLogger(tag);
  67 + LOGGER.error(message);
  68 + }
83 } 69 }
84 70
85 - public static void w(String tag,String msg)  
86 - {  
87 - if (isDebug)  
88 - try {  
89 - Log.w(tag, msg);  
90 - } catch (Exception e) {  
91 - e.printStackTrace();  
92 - } 71 + public static void e(String tag, String message, Throwable exception) {
  72 + if (isDebug) {
  73 + Logger LOGGER = getLogger(tag);
  74 + LOGGER.error(message, exception);
  75 + }
93 } 76 }
94 77
95 - public static void e(String tag, String msg)  
96 - {  
97 - if (isDebug)  
98 - try {  
99 - Log.e(tag, msg);  
100 - } catch (Exception e1) {  
101 - e1.printStackTrace();  
102 - } 78 + private static Logger getLogger(String tag) {
  79 + if (!isConfigured) {
  80 + ConfigureLog4J configureLog4J = new ConfigureLog4J();
  81 + configureLog4J.configure();
  82 + isConfigured = true;
  83 + }
  84 + Logger logger;
  85 + if (TextUtils.isEmpty(tag)) {
  86 + logger = Logger.getRootLogger();
  87 + } else {
  88 + logger = Logger.getLogger(tag);
  89 + }
  90 + return logger;
103 } 91 }
104 92
105 - public static void v(String tag, String msg)  
106 - {  
107 - if (isDebug)  
108 - try {  
109 - Log.v(tag, msg);  
110 - } catch (Exception e) {  
111 - e.printStackTrace();  
112 - } 93 + public static String getExMsg(Exception e) {
  94 + e.printStackTrace();
  95 + ByteArrayOutputStream baos = new ByteArrayOutputStream();
  96 + e.printStackTrace(new PrintStream(baos));
  97 + String exception = baos.toString();
  98 + return exception;
  99 +
113 } 100 }
114 } 101 }
115 \ No newline at end of file 102 \ No newline at end of file
src/com/ectrip/cyt/version/DownApkRunnable.java
@@ -190,7 +190,7 @@ public class DownApkRunnable implements Runnable { @@ -190,7 +190,7 @@ public class DownApkRunnable implements Runnable {
190 int count = 0; 190 int count = 0;
191 byte buf[] = new byte[1024]; 191 byte buf[] = new byte[1024];
192 // 总大小 192 // 总大小
193 - LogUtil.d(df.format((float) length / 1024 / 1024) + "MB"); 193 + LogUtil.d("DownApkRunnable",df.format((float) length / 1024 / 1024) + "MB");
194 do { 194 do {
195 int numread = is.read(buf); 195 int numread = is.read(buf);
196 count += numread; 196 count += numread;
@@ -198,7 +198,7 @@ public class DownApkRunnable implements Runnable { @@ -198,7 +198,7 @@ public class DownApkRunnable implements Runnable {
198 String tmpFileSize = df.format((float) count / 1024 / 1024) + "MB"; 198 String tmpFileSize = df.format((float) count / 1024 / 1024) + "MB";
199 // 当前进度值 199 // 当前进度值
200 progress = (int) (((float) count / length) * 100); 200 progress = (int) (((float) count / length) * 100);
201 - LogUtil.d(numread + "apkFileSize" 201 + LogUtil.d("DownApkRunnable",numread + "apkFileSize"
202 + conn.getContentLength()); 202 + conn.getContentLength());
203 // 更新进度 203 // 更新进度
204 progressBean.setProgress(progress); 204 progressBean.setProgress(progress);
src/com/ectrip/cyt/zxing/camera/FlashlightManager.java
@@ -17,9 +17,9 @@ final class FlashlightManager { @@ -17,9 +17,9 @@ final class FlashlightManager {
17 iHardwareService = getHardwareService(); 17 iHardwareService = getHardwareService();
18 setFlashEnabledMethod = getSetFlashEnabledMethod(iHardwareService); 18 setFlashEnabledMethod = getSetFlashEnabledMethod(iHardwareService);
19 if (iHardwareService == null) { 19 if (iHardwareService == null) {
20 - LogUtil.v(TAG, "This device does supports control of a flashlight"); 20 + LogUtil.i(TAG, "This device does supports control of a flashlight");
21 } else { 21 } else {
22 - LogUtil.v(TAG, "This device does not support control of a flashlight"); 22 + LogUtil.i(TAG, "This device does not support control of a flashlight");
23 } 23 }
24 } 24 }
25 25
src/com/ectrip/trips/net/DataTool.java
@@ -12,6 +12,7 @@ import com.ectrip.cyt.utils.LogUtil; @@ -12,6 +12,7 @@ import com.ectrip.cyt.utils.LogUtil;
12 import com.fourmob.datetimepicker.Utils; 12 import com.fourmob.datetimepicker.Utils;
13 13
14 public class DataTool { 14 public class DataTool {
  15 + public static final String TAG = "DataTool";
15 /** 16 /**
16 * 通过signkey和data验证数据,验证通过会返回true,未通过返回false 17 * 通过signkey和data验证数据,验证通过会返回true,未通过返回false
17 * 不建议外部调用此方法 18 * 不建议外部调用此方法
@@ -79,13 +80,13 @@ public class DataTool { @@ -79,13 +80,13 @@ public class DataTool {
79 try { 80 try {
80 String signData = signkey + data; 81 String signData = signkey + data;
81 String base64 = Base64.encode(signData.getBytes("UTF-8")); 82 String base64 = Base64.encode(signData.getBytes("UTF-8"));
82 - LogUtil.i("responseData:" + base64); 83 + LogUtil.i(TAG,"responseData:" + base64);
83 String responseSign = MD5Util.signMD5(base64,"UTF-8"); 84 String responseSign = MD5Util.signMD5(base64,"UTF-8");
84 - LogUtil.i("responseSign:" + responseSign); 85 + LogUtil.i(TAG,"responseSign:" + responseSign);
85 return responseSign; 86 return responseSign;
86 } catch (UnsupportedEncodingException e) { 87 } catch (UnsupportedEncodingException e) {
87 e.printStackTrace(); 88 e.printStackTrace();
88 - LogUtil.i("OTA Service : getErrorResponseJson : String to xml UTF-8 Error !"); 89 + LogUtil.i(TAG,"OTA Service : getErrorResponseJson : String to xml UTF-8 Error !");
89 }catch (Exception e){ 90 }catch (Exception e){
90 e.printStackTrace(); 91 e.printStackTrace();
91 } 92 }
src/com/ectrip/trips/net/HttpHelper.java
@@ -29,7 +29,7 @@ import com.ectrip.cyt.utils.SharedPreferences2Obj; @@ -29,7 +29,7 @@ import com.ectrip.cyt.utils.SharedPreferences2Obj;
29 * @author jigo 网络访问工具类 29 * @author jigo 网络访问工具类
30 */ 30 */
31 public class HttpHelper extends HttpHelperCore { 31 public class HttpHelper extends HttpHelperCore {
32 - 32 + public static final String TAG = "HttpHelper";
33 private Context mContext; 33 private Context mContext;
34 public static HttpHelper helper = null; 34 public static HttpHelper helper = null;
35 35
@@ -85,11 +85,11 @@ public class HttpHelper extends HttpHelperCore { @@ -85,11 +85,11 @@ public class HttpHelper extends HttpHelperCore {
85 String requestParam = DataTool.envelopeData(orderRequest, MyApp 85 String requestParam = DataTool.envelopeData(orderRequest, MyApp
86 .getInstance().getSignkey(), MyApp.getInstance().getIdentity()); 86 .getInstance().getSignkey(), MyApp.getInstance().getIdentity());
87 map.put("requestParam", requestParam); 87 map.put("requestParam", requestParam);
88 - LogUtil.i(requestParam + "requestParam"); 88 + LogUtil.i(TAG,requestParam + "requestParam");
89 executeHttpPost( 89 executeHttpPost(
90 "http://" + MyApp.getInstance().getServiceIp() + action, "", 90 "http://" + MyApp.getInstance().getServiceIp() + action, "",
91 map, httpCallback, "data", DataTrans.class); 91 map, httpCallback, "data", DataTrans.class);
92 - LogUtil.i("url = " + "http://" + MyApp.getInstance().getServiceIp() + action); 92 + LogUtil.i(TAG,"url = " + "http://" + MyApp.getInstance().getServiceIp() + action);
93 if (testMOdel != null && testMOdel) { // 这个是调试弹框 93 if (testMOdel != null && testMOdel) { // 这个是调试弹框
94 if (type == null) { 94 if (type == null) {
95 return; 95 return;
@@ -127,7 +127,7 @@ public class HttpHelper extends HttpHelperCore { @@ -127,7 +127,7 @@ public class HttpHelper extends HttpHelperCore {
127 String requestParam = DataTool.envelopeData(consumeCount, MyApp 127 String requestParam = DataTool.envelopeData(consumeCount, MyApp
128 .getInstance().getSignkey(), MyApp.getInstance().getIdentity()); 128 .getInstance().getSignkey(), MyApp.getInstance().getIdentity());
129 map.put("requestParam", requestParam); 129 map.put("requestParam", requestParam);
130 - LogUtil.i("requestParam" + requestParam); 130 + LogUtil.i(TAG,"requestParam" + requestParam);
131 executeHttpPost( 131 executeHttpPost(
132 "http://" + MyApp.getInstance().getServiceIp() + action, "", 132 "http://" + MyApp.getInstance().getServiceIp() + action, "",
133 map, httpCallback, "data", DataTrans.class); 133 map, httpCallback, "data", DataTrans.class);
@@ -167,7 +167,7 @@ public class HttpHelper extends HttpHelperCore { @@ -167,7 +167,7 @@ public class HttpHelper extends HttpHelperCore {
167 String requestParam = DataTool.envelopeData(consumeCount, MyApp 167 String requestParam = DataTool.envelopeData(consumeCount, MyApp
168 .getInstance().getSignkey(), MyApp.getInstance().getIdentity()); 168 .getInstance().getSignkey(), MyApp.getInstance().getIdentity());
169 map.put("requestParam", requestParam); 169 map.put("requestParam", requestParam);
170 - LogUtil.i("requestParam" + requestParam); 170 + LogUtil.i(TAG,"requestParam" + requestParam);
171 executeHttpPost( 171 executeHttpPost(
172 "http://" + MyApp.getInstance().getServiceIp() + action, "", 172 "http://" + MyApp.getInstance().getServiceIp() + action, "",
173 map, httpCallback, "data", DataTrans.class); 173 map, httpCallback, "data", DataTrans.class);
@@ -206,7 +206,7 @@ public class HttpHelper extends HttpHelperCore { @@ -206,7 +206,7 @@ public class HttpHelper extends HttpHelperCore {
206 String requestParam = DataTool.envelopeData(consumeCount, MyApp 206 String requestParam = DataTool.envelopeData(consumeCount, MyApp
207 .getInstance().getSignkey(), MyApp.getInstance().getIdentity()); 207 .getInstance().getSignkey(), MyApp.getInstance().getIdentity());
208 map.put("requestParam", requestParam); 208 map.put("requestParam", requestParam);
209 - LogUtil.i("requestParam" + requestParam); 209 + LogUtil.i(TAG,"requestParam" + requestParam);
210 executeHttpPost( 210 executeHttpPost(
211 "http://" + MyApp.getInstance().getServiceIp() + action, "", 211 "http://" + MyApp.getInstance().getServiceIp() + action, "",
212 map, httpCallback, "data", DataTrans.class); 212 map, httpCallback, "data", DataTrans.class);
@@ -243,7 +243,7 @@ public class HttpHelper extends HttpHelperCore { @@ -243,7 +243,7 @@ public class HttpHelper extends HttpHelperCore {
243 MyApp.getInstance().getSignkey(), MyApp.getInstance() 243 MyApp.getInstance().getSignkey(), MyApp.getInstance()
244 .getIdentity()); 244 .getIdentity());
245 map.put("requestParam", requestParam); 245 map.put("requestParam", requestParam);
246 - LogUtil.i("requestParam" + requestParam); 246 + LogUtil.i(TAG,"requestParam" + requestParam);
247 executeHttpPost( 247 executeHttpPost(
248 "http://" + MyApp.getInstance().getServiceIp() + action, "", 248 "http://" + MyApp.getInstance().getServiceIp() + action, "",
249 map, httpCallback, "data", DataTrans.class); 249 map, httpCallback, "data", DataTrans.class);
@@ -288,7 +288,7 @@ public class HttpHelper extends HttpHelperCore { @@ -288,7 +288,7 @@ public class HttpHelper extends HttpHelperCore {
288 MyApp.getInstance().getSignkey(), MyApp.getInstance() 288 MyApp.getInstance().getSignkey(), MyApp.getInstance()
289 .getIdentity()); 289 .getIdentity());
290 map.put("requestParam", requestParam); 290 map.put("requestParam", requestParam);
291 - LogUtil.i("requestParam" + requestParam); 291 + LogUtil.i(TAG,"requestParam" + requestParam);
292 executeHttpPost( 292 executeHttpPost(
293 "http://" + MyApp.getInstance().getServiceIp() + action, "", 293 "http://" + MyApp.getInstance().getServiceIp() + action, "",
294 map, httpCallback, "data", DataTrans.class); 294 map, httpCallback, "data", DataTrans.class);
@@ -330,7 +330,7 @@ public class HttpHelper extends HttpHelperCore { @@ -330,7 +330,7 @@ public class HttpHelper extends HttpHelperCore {
330 String requestParam = DataTool.envelopeData(detectVersionRequest, 330 String requestParam = DataTool.envelopeData(detectVersionRequest,
331 signkey, identity); 331 signkey, identity);
332 map.put("requestParam", requestParam); 332 map.put("requestParam", requestParam);
333 - LogUtil.i("requestParam" + requestParam); 333 + LogUtil.i(TAG,"requestParam" + requestParam);
334 executeHttpPost("http://" + url + action, "", map, httpCallback, 334 executeHttpPost("http://" + url + action, "", map, httpCallback,
335 "data", DataTrans.class); 335 "data", DataTrans.class);
336 } 336 }
@@ -358,7 +358,7 @@ public class HttpHelper extends HttpHelperCore { @@ -358,7 +358,7 @@ public class HttpHelper extends HttpHelperCore {
358 MyApp.getInstance().getSignkey(), MyApp.getInstance() 358 MyApp.getInstance().getSignkey(), MyApp.getInstance()
359 .getIdentity()); 359 .getIdentity());
360 map.put("requestParam", requestParam); 360 map.put("requestParam", requestParam);
361 - LogUtil.i("requestParam" + requestParam); 361 + LogUtil.i(TAG,"requestParam" + requestParam);
362 executeHttpPost( 362 executeHttpPost(
363 "http://" + MyApp.getInstance().getServiceIp() + action, "", 363 "http://" + MyApp.getInstance().getServiceIp() + action, "",
364 map, httpCallback, "data", DataTrans.class); 364 map, httpCallback, "data", DataTrans.class);
src/com/ectrip/trips/net/HttpPostRunnable.java
@@ -233,24 +233,24 @@ public class HttpPostRunnable&lt;T&gt; implements Runnable { @@ -233,24 +233,24 @@ public class HttpPostRunnable&lt;T&gt; implements Runnable {
233 try { 233 try {
234 // 获取服务器返回码 234 // 获取服务器返回码
235 if (connection.getResponseCode() == HttpURLConnection.HTTP_OK) { 235 if (connection.getResponseCode() == HttpURLConnection.HTTP_OK) {
236 - LogUtil.v(TAG, "服务器成功返回网页"); 236 + LogUtil.i(TAG, "服务器成功返回网页");
237 bufReader = new BufferedReader(new InputStreamReader( 237 bufReader = new BufferedReader(new InputStreamReader(
238 connection.getInputStream(), "UTF-8")); 238 connection.getInputStream(), "UTF-8"));
239 while ((line = bufReader.readLine()) != null) { 239 while ((line = bufReader.readLine()) != null) {
240 result.append(line); 240 result.append(line);
241 } 241 }
242 - LogUtil.v(TAG, "返回数据:" + result.toString()); 242 + LogUtil.i(TAG, "返回数据:" + result.toString());
243 } else if (connection.getResponseCode() == 400) { 243 } else if (connection.getResponseCode() == 400) {
244 - LogUtil.v(TAG, "服务器不理解请求的语法"); 244 + LogUtil.i(TAG, "服务器不理解请求的语法");
245 return "CODE-"+"400错误!"; 245 return "CODE-"+"400错误!";
246 } else if (connection.getResponseCode() == 404) { 246 } else if (connection.getResponseCode() == 404) {
247 - LogUtil.v(TAG, "服务器找不到请求的网页"); 247 + LogUtil.i(TAG, "服务器找不到请求的网页");
248 return "CODE-"+"404错误!"; 248 return "CODE-"+"404错误!";
249 } else if (connection.getResponseCode() == 500) { 249 } else if (connection.getResponseCode() == 500) {
250 - LogUtil.v(TAG, "服务端升级或者服务端程序有问题:500"); 250 + LogUtil.i(TAG, "服务端升级或者服务端程序有问题:500");
251 return "CODE-"+"500错误!"; 251 return "CODE-"+"500错误!";
252 } else { 252 } else {
253 - LogUtil.v(TAG, "响应失败" + connection.getResponseCode()); 253 + LogUtil.i(TAG, "响应失败" + connection.getResponseCode());
254 return "CODE-"+"响应失败" + connection.getResponseCode(); 254 return "CODE-"+"响应失败" + connection.getResponseCode();
255 } 255 }
256 } catch (IOException e) { 256 } catch (IOException e) {