-
-
Notifications
You must be signed in to change notification settings - Fork 839
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
Stream command output to logger #346
base: development
Are you sure you want to change the base?
Conversation
hey @bdubertret any update on this PR from project leads? I am also interested in this feature as we have long running executables that we would like to see the log. |
} | ||
stderr, err := cmd.StderrPipe() | ||
if err != nil { | ||
log.Fatal(err) |
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.
same
log.Fatal(err) | ||
} | ||
if err := cmd.Start(); err != nil { | ||
log.Fatal(err) |
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.
same
out, err := cmd.CombinedOutput() | ||
stdout, err := cmd.StdoutPipe() | ||
if err != nil { | ||
log.Fatal(err) |
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.
Don't call log.Fatal
. Change these to something like:
log.Printf("[%s] error opening stdout: %s", rid, err)
return "", err
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.
Sorry this has been sitting for so long. I like this PR and want to get it merged. However, there are merge conflicts now and a few changes I'd like to see made before we merge.
I'd be happy to rebase so we can get this live |
This PR tries to fix #345 by using a
TeeReader
on the command stdout and stderr, and streaming the output to the log as it comes from the invoked command.Following discution on my original PR #344, i have rewritten this PR to follow @moorereason 's advice (request to merge on
development
branch, remove unrelated commit)