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.0版本改动预览/讨论 #21

Closed
Muyangmin opened this issue Dec 20, 2016 · 5 comments
Closed

2.0版本改动预览/讨论 #21

Muyangmin opened this issue Dec 20, 2016 · 5 comments
Assignees
Milestone

Comments

@Muyangmin
Copy link
Member

2.0版本计划包含以下改动:

  • 增加对部分集合类的自动格式化处理,例如Array, HashMap, SparseXXXArray等;  
  • 增加日志所在的线程信息输出(默认关闭);  
  • 增加分组策略,便于大型项目内部实现日志分组和拦截;
  • 配合分组策略,原有的Controller模式可能会改为Interceptor,分为全局和动态的拦截器;
  • 剥离Timer模块并作为一个独立辅助工具使用,减小主lib的体积;
  • 剥离FileLogger,理由同上;
  • 加入自定义输出Style的支持 关爱强迫症患者,但是我们仍然建议使用简洁的输出
  • 使用support-annotation库辅助标记API(会使用provided以避免与使用者的support库版本冲突)

欢迎在这个issue下讨论。

@kaleai
Copy link

kaleai commented Dec 21, 2016

format这个作为以附加依赖 compile 'org.mym.plog:android-plog:format: ${latestVersion}'

new ConfigBuilder().setXXXForamt()来做。

@Muyangmin
Copy link
Member Author

@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都会失效。

@kaleai
Copy link

kaleai commented Dec 21, 2016

PLogConfig.newBuilder().setFormater(new DefaultFormater());默认就一个格式化工具。我的意思是这样就可以把格式化分割出去,因为我看到了你准备支持Array, HashMap, SparseXXXArray等对象的格式化,所以我举得可以提供一个默认的格式化类。

style的话咱们默认有个style,但是格式化可以不提供默认的。这样可以允许使用者看自己是否需要格式化的功能,如果要就加入defaultFormater。

@Muyangmin
Copy link
Member Author

这样的话也可以。并且如果要独立出去的话,我觉得这个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();

@kaleai
Copy link

kaleai commented Dec 26, 2016

嗯,可以,我觉得就没有什么问题了。timber的事情有什么疑惑么,可以接下来探讨那个。

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