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

Avoid usage of low-level logging call Log.println? #17

Open
G00fY2 opened this issue Sep 28, 2022 · 0 comments
Open

Avoid usage of low-level logging call Log.println? #17

G00fY2 opened this issue Sep 28, 2022 · 0 comments

Comments

@G00fY2
Copy link

G00fY2 commented Sep 28, 2022

If the Log level is != ASSERT the library uses the low-level logging method Log.println(priority, tag, part).

I know that this part is borrowed from Timber, but I wonder what the benefit of this is, over using the corresponding higher level log methods (Log.v, Log.d ...)? Because from my understanding (have not tested it) this will prevent R8 from removing the logging calls with this recommended and commonly used proguard rule:

-assumenosideeffects class android.util.Log {
    public static boolean isLoggable(java.lang.String, int);
    public static int v(...);
    public static int i(...);
    public static int w(...);
    public static int d(...);
    public static int e(...);
}

I would suggest to change the logToLogcat function to this:

private fun logToLogcat(
  priority: LogPriority,
  tag: String,
  part: String
  ) {
    when (priority) {
      LogPriority.VERBOSE -> Log.v(tag, part)
      LogPriority.DEBUG -> Log.d(tag, part)
      LogPriority.INFO -> Log.i(tag, part)
      LogPriority.WARN -> Log.w(tag, part)
      LogPriority.ERROR -> Log.e(tag, part)
      LogPriority.ASSERT -> Log.wtf(tag, part)
    }
}

Any opinions?

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

No branches or pull requests

1 participant