Commit c0c530835705fdba1cd8a1b01e5bbde96951889e
1 parent
d77aad46
畅游通核销app: 1.增加本地写入日志
Showing
19 changed files
with
142 additions
and
147 deletions
.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 | 98 | <orderEntry type="library" name="Gradle: ./libs/zxing.jar" level="project" /> | 
| 99 | 99 | <orderEntry type="library" name="Gradle: ./libs/gson-2.6.2.jar" level="project" /> | 
| 100 | 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 | 103 | <orderEntry type="library" name="Gradle: ./libs/bw_pos_sdk2.0.18.jar" level="project" /> | 
| 102 | 104 | </component> | 
| 103 | 105 | </module> | 
| 104 | 106 | \ No newline at end of file | ... | ... | 
build.gradle
| ... | ... | @@ -31,6 +31,8 @@ dependencies { | 
| 31 | 31 | implementation files('libs/zxing.jar') | 
| 32 | 32 | implementation files('libs/gson-2.6.2.jar') | 
| 33 | 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 | 36 | compileOnly files('external_libs/classes_2.1.11_20160907.jar') | 
| 35 | 37 | compileOnly files('external_libs/bw_odm_20160526.jar') | 
| 36 | 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 | 216 | if (address == null) { | 
| 217 | 217 | break; | 
| 218 | 218 | } | 
| 219 | - LogUtil.i("address" + address); | |
| 219 | + LogUtil.i(TAG,"address" + address); | |
| 220 | 220 | // 获取设备进行连接 | 
| 221 | 221 | BluetoothDevice device = mBluetoothAdapter | 
| 222 | 222 | .getRemoteDevice(address); | 
| ... | ... | @@ -274,7 +274,7 @@ public class MobilePrintTool extends Activity { | 
| 274 | 274 | printer = new PrinterEscCmd(); | 
| 275 | 275 | } | 
| 276 | 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 | 278 | new Thread(new Runnable() { | 
| 279 | 279 | @Override | 
| 280 | 280 | public void run() { | ... | ... | 
src/com/ectrip/cyt/config/MyApp.java
| ... | ... | @@ -529,7 +529,7 @@ public class MyApp extends BaseApplication { | 
| 529 | 529 | intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); | 
| 530 | 530 | startActivity(intent); | 
| 531 | 531 | } catch (Exception e) { | 
| 532 | - LogUtil.v(TAG, | |
| 532 | + LogUtil.i(TAG, | |
| 533 | 533 | "open network settings failed, please check..."); | 
| 534 | 534 | e.printStackTrace(); | 
| 535 | 535 | } | ... | ... | 
src/com/ectrip/cyt/exceptionsave/debug/LocalLogRunnable.java
| ... | ... | @@ -8,6 +8,7 @@ import java.util.Calendar; | 
| 8 | 8 | import java.util.Date; | 
| 9 | 9 | |
| 10 | 10 | import com.ectrip.cyt.exceptionsave.init.InitAppValue; | 
| 11 | +import com.ectrip.cyt.utils.LogUtil; | |
| 11 | 12 | |
| 12 | 13 | import android.content.Context; | 
| 13 | 14 | import android.content.Intent; | 
| ... | ... | @@ -19,7 +20,7 @@ import android.util.Log; | 
| 19 | 20 | |
| 20 | 21 | public class LocalLogRunnable implements Runnable{ | 
| 21 | 22 | |
| 22 | - private String TAG="LocalLogRunnable"; | |
| 23 | + private static final String TAG="LocalLogRunnable"; | |
| 23 | 24 | |
| 24 | 25 | private Context mContext; | 
| 25 | 26 | private Throwable ex; | 
| ... | ... | @@ -174,6 +175,7 @@ public class LocalLogRunnable implements Runnable{ | 
| 174 | 175 | randomFile.close(); | 
| 175 | 176 | } catch (IOException e) { | 
| 176 | 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 | 231 | } | 
| 232 | 232 | isPause.set(true); | 
| 233 | 233 | super.onBackPressed(); | 
| 234 | - LogUtil.i(getString(R.string.back_pressed)); | |
| 234 | + LogUtil.i(TAG,getString(R.string.back_pressed)); | |
| 235 | 235 | if (netDialog != null && netDialog.isShowing()) { | 
| 236 | 236 | try { | 
| 237 | 237 | netDialog.dismiss(); | ... | ... | 
src/com/ectrip/cyt/ui/MainActivity.java
| ... | ... | @@ -157,14 +157,14 @@ public class MainActivity extends BaseActivity implements OnItemClickListener, V | 
| 157 | 157 | && getSerialNumber().contains("CTY") && getSerialNumber() | 
| 158 | 158 | .substring(0, 3).equals("CTY"))) { | 
| 159 | 159 | // 新的pos机 | 
| 160 | - LogUtil.i(getString(R.string.new_pos)); | |
| 160 | + LogUtil.i(TAG,getString(R.string.new_pos)); | |
| 161 | 161 | SharedPreferences2Obj.getInstance(MainActivity.this) | 
| 162 | 162 | .setName("MachineType") | 
| 163 | 163 | .setObject("type", DeviceType.New_POS.getValue()); | 
| 164 | 164 | } else if (DevicTool.getInstance().isHiboryPos()) { | 
| 165 | 165 | LogUtil.d(TAG, "5501H手持机"); | 
| 166 | 166 | // 5501H手持机 | 
| 167 | - LogUtil.i(getString(R.string.handset)); | |
| 167 | + LogUtil.i(TAG,getString(R.string.handset)); | |
| 168 | 168 | SharedPreferences2Obj.getInstance(MainActivity.this) | 
| 169 | 169 | .setName("MachineType") | 
| 170 | 170 | .setObject("type", DeviceType.BLACK_ID_POS.getValue()); | 
| ... | ... | @@ -173,7 +173,7 @@ public class MainActivity extends BaseActivity implements OnItemClickListener, V | 
| 173 | 173 | .substring(0, 2).equals("LY"))) { | 
| 174 | 174 | release(); | 
| 175 | 175 | // 新的手持pos机 | 
| 176 | - LogUtil.i(getString(R.string.new_handset_pos)); | |
| 176 | + LogUtil.i(TAG,getString(R.string.new_handset_pos)); | |
| 177 | 177 | SharedPreferences2Obj | 
| 178 | 178 | .getInstance(MainActivity.this) | 
| 179 | 179 | .setName("MachineType") | 
| ... | ... | @@ -183,13 +183,13 @@ public class MainActivity extends BaseActivity implements OnItemClickListener, V | 
| 183 | 183 | && getSerialNumber().contains("DY") && getSerialNumber() | 
| 184 | 184 | .substring(0, 2).equals("DY"))) { | 
| 185 | 185 | // 新的身份证pos机 | 
| 186 | - LogUtil.i(getString(R.string.new_id_pos)); | |
| 186 | + LogUtil.i(TAG,getString(R.string.new_id_pos)); | |
| 187 | 187 | SharedPreferences2Obj.getInstance(MainActivity.this) | 
| 188 | 188 | .setName("MachineType") | 
| 189 | 189 | .setObject("type", DeviceType.New_IDPOS.getValue()); | 
| 190 | 190 | } else if (HdxUtil.SetIDCARDPower(1) != -1) { | 
| 191 | 191 | // 身份证pos机 | 
| 192 | - LogUtil.i(getString(R.string.id_pos)); | |
| 192 | + LogUtil.i(TAG,getString(R.string.id_pos)); | |
| 193 | 193 | SharedPreferences2Obj.getInstance(MainActivity.this) | 
| 194 | 194 | .setName("MachineType") | 
| 195 | 195 | .setObject("type", DeviceType.ID_POS.getValue()); | 
| ... | ... | @@ -197,7 +197,7 @@ public class MainActivity extends BaseActivity implements OnItemClickListener, V | 
| 197 | 197 | || DevicTool.getInstance().isSerialPortHandset()) { | 
| 198 | 198 | release(); | 
| 199 | 199 | // 黄色手持机 | 
| 200 | - LogUtil.i(getString(R.string.handset)); | |
| 200 | + LogUtil.i(TAG,getString(R.string.handset)); | |
| 201 | 201 | SharedPreferences2Obj.getInstance(MainActivity.this) | 
| 202 | 202 | .setName("MachineType") | 
| 203 | 203 | .setObject("type", DeviceType.HANDSET.getValue()); | 
| ... | ... | @@ -207,14 +207,14 @@ public class MainActivity extends BaseActivity implements OnItemClickListener, V | 
| 207 | 207 | && height <= 500) { | 
| 208 | 208 | release(); | 
| 209 | 209 | // 小pos机 | 
| 210 | - LogUtil.i(getString(R.string.small_pos)); | |
| 210 | + LogUtil.i(TAG,getString(R.string.small_pos)); | |
| 211 | 211 | SharedPreferences2Obj.getInstance(MainActivity.this) | 
| 212 | 212 | .setName("MachineType") | 
| 213 | 213 | .setObject("type", DeviceType.SMALL_POS.getValue()); | 
| 214 | 214 | } else if (DevicTool.getInstance().isSerialPort() | 
| 215 | 215 | || DevicTool.getInstance().isIdPosPrint()) { | 
| 216 | 216 | // 一般pos机 | 
| 217 | - LogUtil.i(getString(R.string.general_pos)); | |
| 217 | + LogUtil.i(TAG,getString(R.string.general_pos)); | |
| 218 | 218 | SharedPreferences2Obj.getInstance(MainActivity.this) | 
| 219 | 219 | .setName("MachineType") | 
| 220 | 220 | .setObject("type", DeviceType.GENERAL_POS.getValue()); | 
| ... | ... | @@ -222,7 +222,7 @@ public class MainActivity extends BaseActivity implements OnItemClickListener, V | 
| 222 | 222 | //盛本pos机测试******************************* | 
| 223 | 223 | else if (BindService.getInstance().isBasewin()) { | 
| 224 | 224 | // 盛本pos机 | 
| 225 | - LogUtil.i("盛本POS机"); | |
| 225 | + LogUtil.i(TAG,"盛本POS机"); | |
| 226 | 226 | SharedPreferences2Obj.getInstance(MainActivity.this) | 
| 227 | 227 | .setName("MachineType") | 
| 228 | 228 | .setObject("type", DeviceType.BASEWIN_REB_POS.getValue()); | 
| ... | ... | @@ -231,7 +231,7 @@ public class MainActivity extends BaseActivity implements OnItemClickListener, V | 
| 231 | 231 | else { | 
| 232 | 232 | release(); | 
| 233 | 233 | // 手机 | 
| 234 | - LogUtil.i(getString(R.string.mobile)); | |
| 234 | + LogUtil.i(TAG,getString(R.string.mobile)); | |
| 235 | 235 | SharedPreferences2Obj.getInstance(MainActivity.this) | 
| 236 | 236 | .setName("MachineType") | 
| 237 | 237 | .setObject("type", DeviceType.MOBILE.getValue()); | ... | ... | 
src/com/ectrip/cyt/ui/NewHandleScanerActivity.java
| ... | ... | @@ -159,7 +159,7 @@ public class NewHandleScanerActivity extends BaseActivity { | 
| 159 | 159 | } else { | 
| 160 | 160 | try { | 
| 161 | 161 | if (result.startsWith("CYT_")) { | 
| 162 | - LogUtil.i("result = " + result); | |
| 162 | + LogUtil.i(TAG,"result = " + result); | |
| 163 | 163 | typeScan = 0; | 
| 164 | 164 | if (result.contains(",")) { | 
| 165 | 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 | 177 | QRCodeOrderListActivity.class); | 
| 178 | 178 | intent.putExtra("mode", 1); | 
| 179 | 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 | 181 | intent.putExtra("titleName", getString(R.string.show_result)); | 
| 182 | 182 | intent.putExtra("typeScan", typeScan); | 
| 183 | 183 | startActivity(intent); | ... | ... | 
src/com/ectrip/cyt/ui/ScanerHandsetActivity.java
| ... | ... | @@ -189,7 +189,7 @@ public class ScanerHandsetActivity extends SerialPortHandsetActivity { | 
| 189 | 189 | QRCodeOrderListActivity.class); | 
| 190 | 190 | intent.putExtra("mode", 1); | 
| 191 | 191 | intent.putExtra("input_orid", resultString); | 
| 192 | - LogUtil.i("scan_result:" + resultString); | |
| 192 | + LogUtil.i(TAG,"scan_result:" + resultString); | |
| 193 | 193 | intent.putExtra("titleName", | 
| 194 | 194 | getString(R.string.show_result)); | 
| 195 | 195 | startActivity(intent); | ... | ... | 
src/com/ectrip/cyt/ui/ScanerIdCardActivity.java
| ... | ... | @@ -142,10 +142,10 @@ public class ScanerIdCardActivity extends BaseActivity { | 
| 142 | 142 | public void readIdCard(int num) throws Throwable { | 
| 143 | 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 | 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 | 149 | try { | 
| 150 | 150 | testRead(); | 
| 151 | 151 | } catch (Exception e) { | 
| ... | ... | @@ -170,7 +170,7 @@ public class ScanerIdCardActivity extends BaseActivity { | 
| 170 | 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 | 174 | MToast(ScanerIdCardActivity.this, | 
| 175 | 175 | getString(R.string.read_id_info_fail), | 
| 176 | 176 | MToast.LENGTH_SHORT); | 
| ... | ... | @@ -191,7 +191,7 @@ public class ScanerIdCardActivity extends BaseActivity { | 
| 191 | 191 | } | 
| 192 | 192 | } | 
| 193 | 193 | num = 0; | 
| 194 | - LogUtil.d(getString(R.string.id_auth_fail)); | |
| 194 | + LogUtil.d(TAG,getString(R.string.id_auth_fail)); | |
| 195 | 195 | MToast(ScanerIdCardActivity.this, | 
| 196 | 196 | getString(R.string.id_stick_to_the_back), | 
| 197 | 197 | MToast.LENGTH_SHORT); | ... | ... | 
src/com/ectrip/cyt/ui/SettingsActivity.java
| ... | ... | @@ -635,14 +635,14 @@ public class SettingsActivity extends BaseActivity implements OnClickListener, | 
| 635 | 635 | if (!ec_name.equals("")) { | 
| 636 | 636 | try { | 
| 637 | 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 | 639 | + ec_name); | 
| 640 | 640 | ec_name = AESEncryptor.encrypt(constant.decrypt, ec_name); | 
| 641 | 641 | } catch (Exception ex) { | 
| 642 | 642 | try { | 
| 643 | 643 | ec_name = AESEncryptor.encrypt(constant.decrypt, | 
| 644 | 644 | ec_name); | 
| 645 | - LogUtil.d(getString(R.string.not_successfully_decrypt) | |
| 645 | + LogUtil.d(TAG,getString(R.string.not_successfully_decrypt) | |
| 646 | 646 | + ec_name); | 
| 647 | 647 | } catch (Exception e) { | 
| 648 | 648 | e.printStackTrace(); | ... | ... | 
src/com/ectrip/cyt/utils/LogUtil.java
| 1 | 1 | package com.ectrip.cyt.utils; | 
| 2 | 2 | |
| 3 | +import android.text.TextUtils; | |
| 3 | 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 | 14 | * Log统一管理类 | 
| 7 | 15 | */ | 
| ... | ... | @@ -9,106 +17,85 @@ public class LogUtil | 
| 9 | 17 | { | 
| 10 | 18 | public static boolean isDebug = true;// 是否需要打印bug,可以在application的onCreate函数里面初始化 | 
| 11 | 19 | private static final String TAG = "MyAndroid"; | 
| 12 | - | |
| 20 | + private static boolean isConfigured = false; | |
| 13 | 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 | 102 | \ No newline at end of file | ... | ... | 
src/com/ectrip/cyt/version/DownApkRunnable.java
| ... | ... | @@ -190,7 +190,7 @@ public class DownApkRunnable implements Runnable { | 
| 190 | 190 | int count = 0; | 
| 191 | 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 | 194 | do { | 
| 195 | 195 | int numread = is.read(buf); | 
| 196 | 196 | count += numread; | 
| ... | ... | @@ -198,7 +198,7 @@ public class DownApkRunnable implements Runnable { | 
| 198 | 198 | String tmpFileSize = df.format((float) count / 1024 / 1024) + "MB"; | 
| 199 | 199 | // 当前进度值 | 
| 200 | 200 | progress = (int) (((float) count / length) * 100); | 
| 201 | - LogUtil.d(numread + "apkFileSize" | |
| 201 | + LogUtil.d("DownApkRunnable",numread + "apkFileSize" | |
| 202 | 202 | + conn.getContentLength()); | 
| 203 | 203 | // 更新进度 | 
| 204 | 204 | progressBean.setProgress(progress); | ... | ... | 
src/com/ectrip/cyt/zxing/camera/FlashlightManager.java
| ... | ... | @@ -17,9 +17,9 @@ final class FlashlightManager { | 
| 17 | 17 | iHardwareService = getHardwareService(); | 
| 18 | 18 | setFlashEnabledMethod = getSetFlashEnabledMethod(iHardwareService); | 
| 19 | 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 | 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 | 12 | import com.fourmob.datetimepicker.Utils; | 
| 13 | 13 | |
| 14 | 14 | public class DataTool { | 
| 15 | + public static final String TAG = "DataTool"; | |
| 15 | 16 | /** | 
| 16 | 17 | * 通过signkey和data验证数据,验证通过会返回true,未通过返回false | 
| 17 | 18 | * 不建议外部调用此方法 | 
| ... | ... | @@ -79,13 +80,13 @@ public class DataTool { | 
| 79 | 80 | try { | 
| 80 | 81 | String signData = signkey + data; | 
| 81 | 82 | String base64 = Base64.encode(signData.getBytes("UTF-8")); | 
| 82 | - LogUtil.i("responseData:" + base64); | |
| 83 | + LogUtil.i(TAG,"responseData:" + base64); | |
| 83 | 84 | String responseSign = MD5Util.signMD5(base64,"UTF-8"); | 
| 84 | - LogUtil.i("responseSign:" + responseSign); | |
| 85 | + LogUtil.i(TAG,"responseSign:" + responseSign); | |
| 85 | 86 | return responseSign; | 
| 86 | 87 | } catch (UnsupportedEncodingException e) { | 
| 87 | 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 | 90 | }catch (Exception e){ | 
| 90 | 91 | e.printStackTrace(); | 
| 91 | 92 | } | ... | ... | 
src/com/ectrip/trips/net/HttpHelper.java
| ... | ... | @@ -29,7 +29,7 @@ import com.ectrip.cyt.utils.SharedPreferences2Obj; | 
| 29 | 29 | * @author jigo 网络访问工具类 | 
| 30 | 30 | */ | 
| 31 | 31 | public class HttpHelper extends HttpHelperCore { | 
| 32 | - | |
| 32 | + public static final String TAG = "HttpHelper"; | |
| 33 | 33 | private Context mContext; | 
| 34 | 34 | public static HttpHelper helper = null; | 
| 35 | 35 | |
| ... | ... | @@ -85,11 +85,11 @@ public class HttpHelper extends HttpHelperCore { | 
| 85 | 85 | String requestParam = DataTool.envelopeData(orderRequest, MyApp | 
| 86 | 86 | .getInstance().getSignkey(), MyApp.getInstance().getIdentity()); | 
| 87 | 87 | map.put("requestParam", requestParam); | 
| 88 | - LogUtil.i(requestParam + "requestParam"); | |
| 88 | + LogUtil.i(TAG,requestParam + "requestParam"); | |
| 89 | 89 | executeHttpPost( | 
| 90 | 90 | "http://" + MyApp.getInstance().getServiceIp() + action, "", | 
| 91 | 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 | 93 | if (testMOdel != null && testMOdel) { // 这个是调试弹框 | 
| 94 | 94 | if (type == null) { | 
| 95 | 95 | return; | 
| ... | ... | @@ -127,7 +127,7 @@ public class HttpHelper extends HttpHelperCore { | 
| 127 | 127 | String requestParam = DataTool.envelopeData(consumeCount, MyApp | 
| 128 | 128 | .getInstance().getSignkey(), MyApp.getInstance().getIdentity()); | 
| 129 | 129 | map.put("requestParam", requestParam); | 
| 130 | - LogUtil.i("requestParam" + requestParam); | |
| 130 | + LogUtil.i(TAG,"requestParam" + requestParam); | |
| 131 | 131 | executeHttpPost( | 
| 132 | 132 | "http://" + MyApp.getInstance().getServiceIp() + action, "", | 
| 133 | 133 | map, httpCallback, "data", DataTrans.class); | 
| ... | ... | @@ -167,7 +167,7 @@ public class HttpHelper extends HttpHelperCore { | 
| 167 | 167 | String requestParam = DataTool.envelopeData(consumeCount, MyApp | 
| 168 | 168 | .getInstance().getSignkey(), MyApp.getInstance().getIdentity()); | 
| 169 | 169 | map.put("requestParam", requestParam); | 
| 170 | - LogUtil.i("requestParam" + requestParam); | |
| 170 | + LogUtil.i(TAG,"requestParam" + requestParam); | |
| 171 | 171 | executeHttpPost( | 
| 172 | 172 | "http://" + MyApp.getInstance().getServiceIp() + action, "", | 
| 173 | 173 | map, httpCallback, "data", DataTrans.class); | 
| ... | ... | @@ -206,7 +206,7 @@ public class HttpHelper extends HttpHelperCore { | 
| 206 | 206 | String requestParam = DataTool.envelopeData(consumeCount, MyApp | 
| 207 | 207 | .getInstance().getSignkey(), MyApp.getInstance().getIdentity()); | 
| 208 | 208 | map.put("requestParam", requestParam); | 
| 209 | - LogUtil.i("requestParam" + requestParam); | |
| 209 | + LogUtil.i(TAG,"requestParam" + requestParam); | |
| 210 | 210 | executeHttpPost( | 
| 211 | 211 | "http://" + MyApp.getInstance().getServiceIp() + action, "", | 
| 212 | 212 | map, httpCallback, "data", DataTrans.class); | 
| ... | ... | @@ -243,7 +243,7 @@ public class HttpHelper extends HttpHelperCore { | 
| 243 | 243 | MyApp.getInstance().getSignkey(), MyApp.getInstance() | 
| 244 | 244 | .getIdentity()); | 
| 245 | 245 | map.put("requestParam", requestParam); | 
| 246 | - LogUtil.i("requestParam" + requestParam); | |
| 246 | + LogUtil.i(TAG,"requestParam" + requestParam); | |
| 247 | 247 | executeHttpPost( | 
| 248 | 248 | "http://" + MyApp.getInstance().getServiceIp() + action, "", | 
| 249 | 249 | map, httpCallback, "data", DataTrans.class); | 
| ... | ... | @@ -288,7 +288,7 @@ public class HttpHelper extends HttpHelperCore { | 
| 288 | 288 | MyApp.getInstance().getSignkey(), MyApp.getInstance() | 
| 289 | 289 | .getIdentity()); | 
| 290 | 290 | map.put("requestParam", requestParam); | 
| 291 | - LogUtil.i("requestParam" + requestParam); | |
| 291 | + LogUtil.i(TAG,"requestParam" + requestParam); | |
| 292 | 292 | executeHttpPost( | 
| 293 | 293 | "http://" + MyApp.getInstance().getServiceIp() + action, "", | 
| 294 | 294 | map, httpCallback, "data", DataTrans.class); | 
| ... | ... | @@ -330,7 +330,7 @@ public class HttpHelper extends HttpHelperCore { | 
| 330 | 330 | String requestParam = DataTool.envelopeData(detectVersionRequest, | 
| 331 | 331 | signkey, identity); | 
| 332 | 332 | map.put("requestParam", requestParam); | 
| 333 | - LogUtil.i("requestParam" + requestParam); | |
| 333 | + LogUtil.i(TAG,"requestParam" + requestParam); | |
| 334 | 334 | executeHttpPost("http://" + url + action, "", map, httpCallback, | 
| 335 | 335 | "data", DataTrans.class); | 
| 336 | 336 | } | 
| ... | ... | @@ -358,7 +358,7 @@ public class HttpHelper extends HttpHelperCore { | 
| 358 | 358 | MyApp.getInstance().getSignkey(), MyApp.getInstance() | 
| 359 | 359 | .getIdentity()); | 
| 360 | 360 | map.put("requestParam", requestParam); | 
| 361 | - LogUtil.i("requestParam" + requestParam); | |
| 361 | + LogUtil.i(TAG,"requestParam" + requestParam); | |
| 362 | 362 | executeHttpPost( | 
| 363 | 363 | "http://" + MyApp.getInstance().getServiceIp() + action, "", | 
| 364 | 364 | map, httpCallback, "data", DataTrans.class); | ... | ... | 
src/com/ectrip/trips/net/HttpPostRunnable.java
| ... | ... | @@ -233,24 +233,24 @@ public class HttpPostRunnable<T> implements Runnable { | 
| 233 | 233 | try { | 
| 234 | 234 | // 获取服务器返回码 | 
| 235 | 235 | if (connection.getResponseCode() == HttpURLConnection.HTTP_OK) { | 
| 236 | - LogUtil.v(TAG, "服务器成功返回网页"); | |
| 236 | + LogUtil.i(TAG, "服务器成功返回网页"); | |
| 237 | 237 | bufReader = new BufferedReader(new InputStreamReader( | 
| 238 | 238 | connection.getInputStream(), "UTF-8")); | 
| 239 | 239 | while ((line = bufReader.readLine()) != null) { | 
| 240 | 240 | result.append(line); | 
| 241 | 241 | } | 
| 242 | - LogUtil.v(TAG, "返回数据:" + result.toString()); | |
| 242 | + LogUtil.i(TAG, "返回数据:" + result.toString()); | |
| 243 | 243 | } else if (connection.getResponseCode() == 400) { | 
| 244 | - LogUtil.v(TAG, "服务器不理解请求的语法"); | |
| 244 | + LogUtil.i(TAG, "服务器不理解请求的语法"); | |
| 245 | 245 | return "CODE-"+"400错误!"; | 
| 246 | 246 | } else if (connection.getResponseCode() == 404) { | 
| 247 | - LogUtil.v(TAG, "服务器找不到请求的网页"); | |
| 247 | + LogUtil.i(TAG, "服务器找不到请求的网页"); | |
| 248 | 248 | return "CODE-"+"404错误!"; | 
| 249 | 249 | } else if (connection.getResponseCode() == 500) { | 
| 250 | - LogUtil.v(TAG, "服务端升级或者服务端程序有问题:500"); | |
| 250 | + LogUtil.i(TAG, "服务端升级或者服务端程序有问题:500"); | |
| 251 | 251 | return "CODE-"+"500错误!"; | 
| 252 | 252 | } else { | 
| 253 | - LogUtil.v(TAG, "响应失败" + connection.getResponseCode()); | |
| 253 | + LogUtil.i(TAG, "响应失败" + connection.getResponseCode()); | |
| 254 | 254 | return "CODE-"+"响应失败" + connection.getResponseCode(); | 
| 255 | 255 | } | 
| 256 | 256 | } catch (IOException e) { | ... | ... |