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.0版本改动预览/讨论 #21
Comments
format这个作为以附加依赖 compile 'org.mym.plog:android-plog:format: ${latestVersion}' new ConfigBuilder().setXXXForamt()来做。 |
@tianzhijiexian 应该是拆分Style吧? 如果你指的确实是Format的话,我倒觉得没有必要。因为在实际操作中是需要我们来判断对象类型并决定使用哪一个formatter,如果把这一块交给使用者来设置,可能会变成这样: PLogConfig.newBuilder()
.addFormatter(new CollectionFormatter()) //right
.addFormatter(new ObjectFormatter()) //right
.addFormatter(new JSONFormatter()) //hide by ObjectFormatter! NO EFFECT
.addFormatter(new ThrowableFormatter()) //hide by ObjectFormatter! NO EFFECT
//... 如此则API会变得冗长而难于使用,同时由于不方便约束多个formatter参数的顺序,可能会出现覆盖的现象,在例子中,ObjectFormatter的作用范围明显更大,因此如果按照常规遍历顺序,则后续两个formatter都会失效。 |
PLogConfig.newBuilder().setFormater(new DefaultFormater());默认就一个格式化工具。我的意思是这样就可以把格式化分割出去,因为我看到了你准备支持Array, HashMap, SparseXXXArray等对象的格式化,所以我举得可以提供一个默认的格式化类。 style的话咱们默认有个style,但是格式化可以不提供默认的。这样可以允许使用者看自己是否需要格式化的功能,如果要就加入defaultFormater。 |
这样的话也可以。并且如果要独立出去的话,我觉得这个Formatter还可以提供一些设置位以决定启用哪些类型的格式化,以下是我设想的使用方法: Formatter formatter = new DefaultFormatter(true); //true means enable all supported type
//enable only what i want
formatter.setFormatFlag(FLAG_FMT_JSON | FLAG_FMT_POJO | FLAG_FMT_THROWABLE
| FLAG_FMT_COLLECTION);
//enable only json, etc.
Formatter jsonFormatter= new DefaultFormatter(FLAG_FMT_JSON);
//usage in config
PLogConfig.newBuilder().setFormatter(formatter).build(); |
嗯,可以,我觉得就没有什么问题了。timber的事情有什么疑惑么,可以接下来探讨那个。 |
2.0版本计划包含以下改动:
Array
,HashMap
,SparseXXXArray
等;Timer
模块并作为一个独立辅助工具使用,减小主lib的体积;FileLogger
,理由同上;关爱强迫症患者,但是我们仍然建议使用简洁的输出support-annotation
库辅助标记API(会使用provided
以避免与使用者的support库版本冲突)欢迎在这个issue下讨论。
The text was updated successfully, but these errors were encountered: