Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

说点建议哈,并没有在使用, #2

Closed
AoEiuV020 opened this issue Apr 11, 2017 · 5 comments
Closed

说点建议哈,并没有在使用, #2

AoEiuV020 opened this issue Apr 11, 2017 · 5 comments

Comments

@AoEiuV020
Copy link

主要是些自己的感觉,或者说习惯,也许作者有自己的想法,

不支持给指定tag设置log级别?
这个可以有,虽然是也可以在logcat设置过滤,但这不方便,
可以来个资源文件,管理标签对应的log级别,
或者干脆在最后调用Log类输出日志那里判断一下安卓的Log.isLoggelable(tag,level),

还有表示日志级别的6个常量,首先完全没必要为了一个方法去定义一个注解,
而且其实可以直接用Log里的常量,或者来个方法转换一下,这样最后输出日志可以用一个
Log.println(int priority, String tag, String msg)代替那一大段switch,
Log.v(tag, msg);
Log.d(tag, msg);
Log.i(tag, msg);
Log.w(tag, msg);
Log.e(tag, msg);
Log.wtf(tag, msg);

217行的这个,
if (V == sLogFilter || type >= sLogFilter) {
前一个条件是多余的吧,

@Blankj
Copy link
Owner

Blankj commented Apr 11, 2017

因为用到了枚举型注解,怕你们设置过滤器传参错误,前一个条件是没用哈

@AoEiuV020
Copy link
Author

@Blankj setLogFilter这个设置对所有TAG有效,我说的是每个TAG分别设置日志级别,
比如slf4j-simple的配置文件可以这样,
org.slf4j.simpleLogger.defaultLogLevel=debug
org.slf4j.simpleLogger.log.IndexFragment=info
org.slf4j.simpleLogger.log.Listener=debug
org.slf4j.simpleLogger.log.LoginActivity=trace

@AoEiuV020
Copy link
Author

@Blankj 我意思是既然只有一个方法用到那个注解,不如直接在方法里判断一下,
不过用注解也有个好处,传错了IDE可以实时提醒,
确实我并没有考虑到用户使用ALog常量成员以外的情况,

@Blankj
Copy link
Owner

Blankj commented Apr 11, 2017

该库以精简为主,当然想做到的话在要测试的地方把Builder中的参数改了,测完再恢复回去也可以马马虎虎实现你的需求,你的这个需求应该也不是很大,所以就不追求那么复杂了

@Blankj
Copy link
Owner

Blankj commented Apr 11, 2017

虽说是一个方法,但设置那个过滤器怕传的参数有误,所以还是用了注解型枚举,相比直接用枚举要好

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants