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

chore: Emit Docker and Shell logging to ProgressListener #221

Open
wants to merge 15 commits into
base: main
Choose a base branch
from

Conversation

HBobertz
Copy link
Contributor

@HBobertz HBobertz commented Dec 3, 2024

Fixes #196

There is still a quiet flag however I will do that in another pr as I need to get rid of it in the CDK as well and will probably do it there first

@HBobertz HBobertz marked this pull request as ready for review December 8, 2024 22:14
lib/progress.ts Outdated
@@ -77,7 +77,7 @@ export interface IPublishProgress {
/**
* How far along are we?
*/
readonly percentComplete: number;
readonly percentComplete?: number;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why?

Copy link
Contributor Author

@HBobertz HBobertz Dec 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Percent complete is just a measure of how many assets have been published/built and it's not relevant to what the shell logs are doing so I ignore it when capturing shell logs

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This strongly indicates to me that you are not using the interface called IPublishProgress correctly which defines itself as "Context object for publishing progress".

Comment on lines 13 to 16

/**
* Only match a prefix of the command (don't care about the details of the arguments)
*/
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are you removing comments?

Copy link
Contributor Author

@HBobertz HBobertz Dec 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought it was a bit redundent but I'll add it back

Copy link
Contributor

@mrgrain mrgrain left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please describe what this PR is addressing and how its solving it. If there are follow-up PRs, describe in a bit more detail how they will address it.

Please describe how you've verified the changes.

Comment on lines 45 to 47
if (invocation.stderr) {
// Send stderr data after stdout
if (invocation.stderr) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

???

bin/logging.ts Outdated
percentComplete: percentComplete,
abort: () => {},
};
globalProgressListener.onPublishEvent(logLevelToEventType(level), progressEvent);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So this is sending the log message to the globalProgressListener?
Which in turn when using DefaultProgressListener then calls log?
How does that work?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is needless right now, but I decided to build it this way as I wanted to provide an easy angle by which someone could add progress listeners even if using the cli. It's a bit pre-emptive so I can remove it if we want as it's un-needed complexity at this point.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you are removing progress listeners, what is left in this PR?

My point here was the loop you are creating:

log() -> globalProgressListener.onPublishEvent() -> DefaultProgressListener -> log()

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's also not tested. Pretty sure if you had a test with DefaultProgressListener you would notice that.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but I decided to build it this way as I wanted to provide an easy angle by which someone could add progress listeners even if using the cli.

That's an okay decision. You need to explain these decisions in your PR descrption.

bin/logging.ts Outdated
Comment on lines 64 to 68
if (isError) {
process.stderr.write(text);
} else {
process.stdout.write(text);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So we are still writing directly to stderr and stdout?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah we are doing both for now. I could detect if we are being called directly from publish and ignore printing to stdout but I figured it wouldn't hurt

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Anything written to process.stdout or process.stderr needs also be pluggable

That's the whole point of the work: That nothing is indiscriminately written to stdout/stderr anymore.

@mrgrain
Copy link
Contributor

mrgrain commented Dec 10, 2024

Fixes #196

BTW, if it doesn't close the issue, e.g. because a second PR is needed, you cannot put that in like that.

@HBobertz HBobertz changed the title chore: Modify logging to ensure docker and shell logging is properly emitted to pluggble log publisher chore: Ensure docker and shell logging is properly emitted to log publisher Dec 13, 2024
@HBobertz HBobertz changed the title chore: Ensure docker and shell logging is properly emitted to log publisher chore: Emit Docker and Shell logging to ProgressListener Dec 13, 2024
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

Successfully merging this pull request may close these issues.

All CDK-Assets logging needs to be pluggable
2 participants