How to erase lines printed previously with gradle's logger?

(Bo Zhang) #1

I’m writing a plugin and want to provide log which will erase some lines printed previously, just as :test > xxx tests completed does.

I tried Logger.quiet("\r") and Logger.quiet("\033[2K") but neither of them works.

How can I make it?

Thanks a lot.

(Daniel Lacasse) #2

You would most likely have to use ANSI control characters. However, this is not the intended usage for the logger and is not supported in Gradle. If you explain your use case, we can probably come up with an API to achieve what you are trying to do.

(Bo Zhang) #3

Thanks for your reply.
So you’re saying I can’t make it with logger at present?

Here’s a case: I start a git cloning in gradle, and I want to display the cloing progress in log, i.e., Complete xx%, which means I must erase last line when a new percentage number arrives.

(Daniel Lacasse) #4

It makes a lot of sense. At the moment, you could use the internal API ProgressLogger and ProgressLoggerFactory. Both are used to generate ProgressStartEvent, ProgressEvent and ProgressCompleteEvent which are handled by the console to change the status bar.

That been said, those are internal API and are subject to change without notice. There are some new API in the work to address that specific scenario but I can’t comment on any ETA to delivery.

Don’t hesitate to ask more questions,


(Bo Zhang) #5

Thank you very much!