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

Add support for capturing the output of Processes #135

Merged
merged 8 commits into from
Aug 29, 2022

Conversation

emmayspark
Copy link
Contributor

@emmayspark emmayspark commented Aug 13, 2022

This code supports capturing stderr and stdout logs of Processes.
When Process object is created, Start Information is configured with event handlers to subscribe to events and redirect streams of standard output/errors to the event handlers. Whenever events are raised to event handlers, it writes them to the PF_ConsoleLog.txt until process is terminated or error is captured.

Sample Output For Windows Process:
PF_ConsoleLogs.txt
Sample Output For Linux Process:
PF_ConsoleLogs(Linux).txt

@emmayspark emmayspark requested review from kerdrek and a team August 13, 2022 00:52
VmAgent.Core/Interfaces/ProcessRunner.cs Show resolved Hide resolved
VmAgent.Core/ProcessOutputLogger.cs Outdated Show resolved Hide resolved
VmAgent.Core/ProcessOutputLogger.cs Outdated Show resolved Hide resolved
@yegarci
Copy link
Contributor

yegarci commented Aug 18, 2022

Do you have an example text output for a run?

@emmayspark
Copy link
Contributor Author

@yegarci updated the PR description - check out the link!

@yegarci
Copy link
Contributor

yegarci commented Aug 19, 2022

Sorry, I mean do you have an example output where the new stderror and stdout streams are written?

Copy link

@KalonJ-MSFT KalonJ-MSFT left a comment

Choose a reason for hiding this comment

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

:shipit:

@emmayspark emmayspark force-pushed the emmap/CaptureLogsProcess branch from f6ec94d to a985f5f Compare August 23, 2022 22:04
VmAgent.Core/Dependencies/FileWriteWrapper.cs Outdated Show resolved Hide resolved
VmAgent.Core/Dependencies/FileWriteWrapper.cs Show resolved Hide resolved
VmAgent.Core/Interfaces/ProcessRunner.cs Outdated Show resolved Hide resolved
VmAgent.Core/Interfaces/ProcessRunner.cs Outdated Show resolved Hide resolved
VmAgent.Core/Interfaces/ProcessRunner.cs Outdated Show resolved Hide resolved
VmAgent.Core/ProcessOutputLogger.cs Outdated Show resolved Hide resolved
VmAgent.Core/ProcessOutputLogger.cs Outdated Show resolved Hide resolved
VmAgent.Core/Interfaces/ProcessRunner.cs Outdated Show resolved Hide resolved
Summary: tested code with streamWriter with sample console app to one callback functions is availiable at once and it worked fine. However, multiple filewriter instances will be created not in Main Thread. By using FileWriter.Synchonized(), we can make it thread safe.
VmAgent.Core/Interfaces/ProcessWrapper.cs Outdated Show resolved Hide resolved
VmAgent.Core/Dependencies/FileWriteWrapper.cs Outdated Show resolved Hide resolved
VmAgent.Core/Dependencies/FileWriteWrapper.cs Outdated Show resolved Hide resolved
VmAgent.Core/Dependencies/FileWriteWrapper.cs Show resolved Hide resolved
VmAgent.Core/Dependencies/Interfaces/IFileWriteWrapper.cs Outdated Show resolved Hide resolved
removed default value in interface
@emmayspark emmayspark merged commit ebe538b into main Aug 29, 2022
@emmayspark emmayspark deleted the emmap/CaptureLogsProcess branch August 29, 2022 21:32
brianwp3000 added a commit that referenced this pull request Sep 1, 2022
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.

5 participants