File tree Expand file tree Collapse file tree 4 files changed +36
-1
lines changed
library/src/main/java/com/hjq/logcat Expand file tree Collapse file tree 4 files changed +36
-1
lines changed Original file line number Diff line number Diff line change 1616
1717* [ 在多进程情况下无法展示入口怎么办] ( #在多进程情况下无法展示入口怎么办 )
1818
19+ * [ 相同的 TAG 日志会自动合并打印怎么关闭] ( #相同的-tag-日志会自动合并打印怎么关闭 )
20+
1921#### Logcat 入口配置
2022
2123* 框架默认提供了两种入口
@@ -325,4 +327,23 @@ public final class XxxApplication extends Application {
325327 }
326328 }
327329}
330+ ```
331+
332+ #### 相同的 TAG 日志会自动合并打印怎么关闭
333+
334+ * 当发现有两个及以上相同的 TAG 的日志,且过程中没有插入新 TAG 的日志,为了日志显示的美观,框架会自动进行合并打印,你如果不需要该功能,在清单文件中加入以下配置即可:
335+
336+ ``` xml
337+ <manifest >
338+
339+ <application >
340+
341+ <!-- 日志合并打印(默认开启) -->
342+ <meta-data
343+ android : name =" LogcatAutoMergePrint"
344+ android : value =" false" />
345+
346+ </application >
347+
348+ </manifest >
328349```
Original file line number Diff line number Diff line change 3636 android : name =" LogcatNotifyEntrance"
3737 android : value =" true" />
3838
39+ <!-- <!– 日志合并打印(默认开启) –>-->
40+ <!-- <meta-data-->
41+ <!-- android:name="LogcatAutoMergePrint"-->
42+ <!-- android:value="false" />-->
43+
3944<!-- <!– 默认搜索关键字 –>-->
4045<!-- <meta-data-->
4146<!-- android:name="LogcatDefaultSearchKey"-->
Original file line number Diff line number Diff line change @@ -57,6 +57,7 @@ final class LogcatAdapter extends RecyclerView.Adapter<LogcatAdapter.ViewHolder>
5757
5858 private String mKeyword = "" ;
5959 private String mLogLevel = LogLevel .VERBOSE ;
60+ private boolean mLogAutoMergePrint = true ;
6061
6162 private RecyclerView mRecyclerView ;
6263
@@ -69,6 +70,11 @@ final class LogcatAdapter extends RecyclerView.Adapter<LogcatAdapter.ViewHolder>
6970
7071 public LogcatAdapter (Context context ) {
7172 mContext = context ;
73+ Boolean metaBooleanData = LogcatUtils .getMetaBooleanData (
74+ context , LogcatContract .META_DATA_LOGCAT_AUTO_MERGE_PRINT );
75+ if (metaBooleanData != null ) {
76+ mLogAutoMergePrint = metaBooleanData ;
77+ }
7278 }
7379
7480 @ Override
@@ -103,7 +109,7 @@ List<LogcatInfo> getShowData() {
103109 * 添加单条数据(这个方法有可能会在子线程调用)
104110 */
105111 void addItem (LogcatInfo info ) {
106- if (!mShowData .isEmpty ()) {
112+ if (mLogAutoMergePrint && !mShowData .isEmpty ()) {
107113 LogcatInfo lastInfo = getItem (mShowData .size () - 1 );
108114 if (info .getLevel ().equals (lastInfo .getLevel ()) &&
109115 info .getTag ().equals (lastInfo .getTag ())) {
Original file line number Diff line number Diff line change @@ -14,6 +14,9 @@ final class LogcatContract {
1414 /** 悬浮窗入口 */
1515 static final String META_DATA_LOGCAT_WINDOW_ENTRANCE = "LogcatWindowEntrance" ;
1616
17+ /** 自动合并打印日志(默认开启) */
18+ static final String META_DATA_LOGCAT_AUTO_MERGE_PRINT = "LogcatAutoMergePrint" ;
19+
1720 /** 默认搜索关键字 */
1821 static final String META_DATA_LOGCAT_DEFAULT_SEARCH_KEY = "LogcatDefaultSearchKey" ;
1922
You can’t perform that action at this time.
0 commit comments