-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Adds SingleThreadedLogger to be able to keep a footer for where progress indication will go. #1326
Conversation
…ess indication will go.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got some questions. Maybe due to not being able to see the big picture.
...ins-common/src/main/java/com/google/cloud/tools/jib/plugins/common/SingleThreadedLogger.java
Outdated
Show resolved
Hide resolved
...ins-common/src/main/java/com/google/cloud/tools/jib/plugins/common/SingleThreadedLogger.java
Outdated
Show resolved
Hide resolved
* console | ||
* @return a {@link Future} to track completion | ||
*/ | ||
public Future<Void> log(Runnable messageLogger) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Trying to understand why this needs to be a Runnable
instead of a String
. Isn't it that in the end what this Runnable
will do is to write some string to plainLogger
? Actually, what does "plain" mean here? Also, is it that this "message logger" (who will log a message to the console according to the Javadoc) is a different logger than the plain logger? (I didn't get what these two loggers will be in the end.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So this is for the user to pass like (Maven) () -> log.info("log message")
or other logging method, so that this class is independent of the actual different logging levels.
plain
is for a logging method similar to just plain System.out.print
, so it will be like lifecycle
for Gradle and probably System.out.print
for Maven (might need to do some things differently if wanting to use Maven info logging).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, now I see the intention. Basically, this class is the LogEvent
handler (or will be used by whatever LogEvent
handler) to "move" the footer (the multi-line progress display) down by one line after logging the message (if it gets printed to the screen, for example). This is done by calling this log()
message. And at the same time, this class is the ProgressEvent
handler (or will be used by whatever ProgressEvent
handler) to update the progress display, which is done by setFooter()
. I see where my confusion came from: first, the potential mix of LogEvent
and ProgressEvent
; secondly, the mix of two output channels, one for messageLogger
and plainLogger
(for example, one going out to a file and the other going out to a screen); and the messageLogger
is basically an unrestricted lambda. Not that I am suggesting something concrete here... don't really have an idea.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yea, this will be used by the LogEventHandler
. A ProgressLogger
will be the one that handles ProgressEvent
s and directly calls setFooter
on this or set the footer via a LogEvent
type of CHANGE_FOOTER
or something.
...ins-common/src/main/java/com/google/cloud/tools/jib/plugins/common/SingleThreadedLogger.java
Outdated
Show resolved
Hide resolved
...ins-common/src/main/java/com/google/cloud/tools/jib/plugins/common/SingleThreadedLogger.java
Outdated
Show resolved
Hide resolved
...ins-common/src/main/java/com/google/cloud/tools/jib/plugins/common/SingleThreadedLogger.java
Outdated
Show resolved
Hide resolved
...ins-common/src/main/java/com/google/cloud/tools/jib/plugins/common/SingleThreadedLogger.java
Outdated
Show resolved
Hide resolved
...ins-common/src/main/java/com/google/cloud/tools/jib/plugins/common/SingleThreadedLogger.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK from my side. Renaming the class sounds good.
...common/src/test/java/com/google/cloud/tools/jib/plugins/common/SingleThreadedLoggerTest.java
Outdated
Show resolved
Hide resolved
...ins-common/src/main/java/com/google/cloud/tools/jib/plugins/common/SingleThreadedLogger.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, but I have one comment after you introduced shutdown
.
Part of #1297
This will be gradually improved once it is used in the
LogEventHandler
.