jib icon indicating copy to clipboard operation
jib copied to clipboard

Set up Error Prone check to prevent use of native Gradle and Maven loggers

Open chanseokoh opened this issue 6 years ago • 9 comments

Using the native Gradle logger was probably why our deprecation messages were overwritten.

We should be careful not to make use of the native Maven or Gradle loggers. We can prevent misuse in ProjectProperties by just using consoleLogger. But it is very easy to accidentally use the native loggers in Maven mojos and Gradle tasks. Unfortunately, now I realized we had used the native loggers when printing deprecation notices.

chanseokoh avatar Nov 25 '19 21:11 chanseokoh

That's weird, We shouldn't be overwriting any logs should we, even if it does use the native logger.

loosebazooka avatar Nov 25 '19 21:11 loosebazooka

I think it's because of the progress bar

TadCordle avatar Nov 25 '19 21:11 TadCordle

#2176 will fix wrong usage at the moment. But we should keep in mind that it is easy to accidentally do getLog() or getLogger() in mojos and tasks, because that's the only way to get a logger there.

chanseokoh avatar Nov 25 '19 21:11 chanseokoh

But I think we should be using the native logger as much as we can... it helps us conform to whatever logging settings are set, no? Or am I missing something?

loosebazooka avatar Nov 25 '19 21:11 loosebazooka

oh I see native logger vs our logging events?

loosebazooka avatar Nov 25 '19 21:11 loosebazooka

We can add an errorprone check for this :)

loosebazooka avatar Nov 25 '19 21:11 loosebazooka

I meant using ConsoleLogger that we create for the progress bar (enabled by default). ConsoleLogger sits on top of the native logger and makes use of it. But if we by-pass ConsoleLogger and go directly with the native logger, such output can be overwritten a mess because ConsoleLogger does frequent cursor-ups. If you see #2176, it might make more sense.

I don't know how can we prevent this with errorprone?

chanseokoh avatar Nov 25 '19 22:11 chanseokoh

I think we can ask error prone to mark any use of the gradle logger or maven logger as unsafe in our codebase, just speculating though. (we would write this check)

loosebazooka avatar Nov 25 '19 22:11 loosebazooka

I tried to see how Error Prone can be configured to detect this. Looks like we have to write a custom check in Java. This seems fairly involved. May need to create another Gradle sub-project. I'll rename this issue and add the "tech debt" label to be open.

chanseokoh avatar Nov 27 '19 18:11 chanseokoh