orhanobut / logger

✔️ Simple, pretty and powerful logger for android
Apache License 2.0
13.78k stars 2.14k forks source link

The design of the restriction position for "isLoggable" is unreasonable #269

Open qlang122 opened 6 months ago

qlang122 commented 6 months ago

The problem of design thinking!

Logger.json() -> LoggerPrinter.json() (json format in here, Time-consuming) -> LoggerPrinter.d() -> LoggerPrinter.log()

Action code:

for (LogAdapter adapter : logAdapters) {
      if (adapter.isLoggable(priority, tag)) {
        adapter.log(priority, tag, message);
      }
}

Why is this design problematic?

Because many users actually do this:

Logger.addLogAdapter(object : AndroidLogAdapter(formatStrategy) {
      override fun isLoggable(priority: Int, tag: String?): Boolean {
            return BuildConfig.DEBUG
      }
})

And that's where the problem lies image