EpLog.java 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242
  1. package com.epson.mobilephone.common;
  2. import android.os.Debug;
  3. import android.support.p000v4.media.session.PlaybackStateCompat;
  4. import android.util.Log;
  5. import epson.print.CommonDefine;
  6. import java.text.DecimalFormat;
  7. public final class EpLog {
  8. public static final String TAG = "Epson App";
  9. private static boolean isDebug = false;
  10. private static String null2str(String str) {
  11. return str == null ? "(null)" : str;
  12. }
  13. private EpLog() {
  14. }
  15. public static void setDebuggable(boolean z) {
  16. if (z) {
  17. isDebug = true;
  18. } else {
  19. isDebug = false;
  20. }
  21. }
  22. /* renamed from: v */
  23. public static void m79v() {
  24. if (isDebug) {
  25. Log.v("Epson App", getMetaInfo());
  26. }
  27. }
  28. /* renamed from: v */
  29. public static void m80v(String str) {
  30. if (isDebug) {
  31. Log.v("Epson App", getMetaInfo() + null2str(str));
  32. }
  33. }
  34. /* renamed from: v */
  35. public static void m81v(String str, String str2) {
  36. if (isDebug) {
  37. Log.v(str, getMetaInfo() + null2str(str2));
  38. }
  39. }
  40. /* renamed from: d */
  41. public static void m68d() {
  42. if (isDebug) {
  43. Log.d("Epson App", getMetaInfo());
  44. }
  45. }
  46. /* renamed from: d */
  47. public static void m69d(String str) {
  48. if (isDebug) {
  49. Log.d("Epson App", getMetaInfo() + null2str(str));
  50. }
  51. }
  52. /* renamed from: d */
  53. public static void m70d(String str, String str2) {
  54. if (isDebug) {
  55. Log.d(str, getMetaInfo() + null2str(str2));
  56. }
  57. }
  58. /* renamed from: i */
  59. public static void m76i() {
  60. if (isDebug) {
  61. Log.i("Epson App", getMetaInfo());
  62. }
  63. }
  64. /* renamed from: i */
  65. public static void m77i(String str) {
  66. if (isDebug) {
  67. Log.i("Epson App", getMetaInfo() + null2str(str));
  68. }
  69. }
  70. /* renamed from: i */
  71. public static void m78i(String str, String str2) {
  72. if (isDebug) {
  73. Log.i(str, getMetaInfo() + null2str(str2));
  74. }
  75. }
  76. /* renamed from: w */
  77. public static void m82w(String str) {
  78. if (isDebug) {
  79. Log.w("Epson App", getMetaInfo() + null2str(str));
  80. }
  81. }
  82. /* renamed from: w */
  83. public static void m83w(String str, String str2) {
  84. if (isDebug) {
  85. Log.w(str, getMetaInfo() + null2str(str2));
  86. }
  87. }
  88. /* renamed from: w */
  89. public static void m85w(String str, Throwable th) {
  90. if (isDebug) {
  91. Log.w("Epson App", getMetaInfo() + null2str(str), th);
  92. printThrowable(th);
  93. if (th.getCause() != null) {
  94. printThrowable(th.getCause());
  95. }
  96. }
  97. }
  98. /* renamed from: w */
  99. public static void m84w(String str, String str2, Throwable th) {
  100. if (isDebug) {
  101. Log.w(str, getMetaInfo() + null2str(str2), th);
  102. printThrowable(str, th);
  103. if (th.getCause() != null) {
  104. printThrowable(th.getCause());
  105. }
  106. }
  107. }
  108. /* renamed from: e */
  109. public static void m71e(String str) {
  110. if (isDebug) {
  111. Log.e("Epson App", getMetaInfo() + null2str(str));
  112. }
  113. }
  114. /* renamed from: e */
  115. public static void m72e(String str, String str2) {
  116. if (isDebug) {
  117. Log.e(str, getMetaInfo() + null2str(str2));
  118. }
  119. }
  120. /* renamed from: e */
  121. public static void m74e(String str, Throwable th) {
  122. if (isDebug) {
  123. Log.e("Epson App", getMetaInfo() + null2str(str), th);
  124. printThrowable(th);
  125. if (th.getCause() != null) {
  126. printThrowable(th.getCause());
  127. }
  128. }
  129. }
  130. /* renamed from: e */
  131. public static void m73e(String str, String str2, Throwable th) {
  132. if (isDebug) {
  133. Log.e(str, getMetaInfo() + null2str(str2), th);
  134. printThrowable(str, th);
  135. if (th.getCause() != null) {
  136. printThrowable(th.getCause());
  137. }
  138. }
  139. }
  140. /* renamed from: e */
  141. public static void m75e(Throwable th) {
  142. if (isDebug) {
  143. printThrowable(th);
  144. if (th.getCause() != null) {
  145. printThrowable(th.getCause());
  146. }
  147. }
  148. }
  149. private static void printThrowable(Throwable th) {
  150. Log.e("Epson App", th.getClass().getName() + ": " + th.getMessage());
  151. for (StackTraceElement stackTraceElement : th.getStackTrace()) {
  152. Log.e("Epson App", " at " + getMetaInfo(stackTraceElement));
  153. }
  154. }
  155. private static void printThrowable(String str, Throwable th) {
  156. Log.e(str, th.getClass().getName() + ": " + th.getMessage());
  157. for (StackTraceElement stackTraceElement : th.getStackTrace()) {
  158. Log.e("Epson App", " at " + getMetaInfo(stackTraceElement));
  159. }
  160. }
  161. private static String getMetaInfo() {
  162. return getMetaInfo(Thread.currentThread().getStackTrace()[4]);
  163. }
  164. public static String getMetaInfo(StackTraceElement stackTraceElement) {
  165. StringBuffer stringBuffer = new StringBuffer();
  166. String className = stackTraceElement.getClassName();
  167. String substring = className.substring(className.lastIndexOf(CommonDefine.DOT) + 1);
  168. String methodName = stackTraceElement.getMethodName();
  169. int lineNumber = stackTraceElement.getLineNumber();
  170. stringBuffer.append("[");
  171. stringBuffer.append(substring);
  172. stringBuffer.append("#");
  173. stringBuffer.append(methodName);
  174. stringBuffer.append(":");
  175. stringBuffer.append(lineNumber);
  176. stringBuffer.append("]");
  177. return new String(stringBuffer);
  178. }
  179. public static final void heap() {
  180. heap("Epson App");
  181. }
  182. public static final void heap(String str) {
  183. if (isDebug) {
  184. DecimalFormat decimalFormat = new DecimalFormat("0.00");
  185. StringBuffer stringBuffer = new StringBuffer();
  186. stringBuffer.append("Native heap : Free=");
  187. stringBuffer.append(Long.toString(Debug.getNativeHeapFreeSize() / PlaybackStateCompat.ACTION_PLAY_FROM_MEDIA_ID));
  188. stringBuffer.append("kb");
  189. stringBuffer.append(", Allocated=");
  190. stringBuffer.append(decimalFormat.format(((Debug.getNativeHeapAllocatedSize()) / 1024.0d) / 1024.0d));
  191. stringBuffer.append("MB");
  192. stringBuffer.append(", Size=");
  193. stringBuffer.append(decimalFormat.format(((Debug.getNativeHeapSize()) / 1024.0d) / 1024.0d));
  194. stringBuffer.append("MB");
  195. stringBuffer.append(System.getProperty("line.separator"));
  196. stringBuffer.append("Dalvik heap : Free=");
  197. stringBuffer.append(Long.toString(Runtime.getRuntime().freeMemory() / PlaybackStateCompat.ACTION_PLAY_FROM_MEDIA_ID));
  198. stringBuffer.append("kb");
  199. stringBuffer.append(", Total=");
  200. stringBuffer.append(decimalFormat.format(((Runtime.getRuntime().totalMemory()) / 1024.0d) / 1024.0d));
  201. stringBuffer.append("MB");
  202. stringBuffer.append(", Now Size=");
  203. stringBuffer.append(decimalFormat.format((((Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory())) / 1024.0d) / 1024.0d));
  204. stringBuffer.append("MB");
  205. stringBuffer.append(", MAX Size=");
  206. stringBuffer.append(decimalFormat.format(((Runtime.getRuntime().maxMemory()) / 1024.0d) / 1024.0d));
  207. stringBuffer.append("MB");
  208. Log.i(str, new String(stringBuffer));
  209. }
  210. }
  211. }