Add log passthrough for lock-exec#26
Conversation
7a104a0 to
a1b859e
Compare
|
👀 just curious what you'll expect to happen with cron logs when this goes to prod. got any prediction? |
| cmd := exec.CommandContext(ctx, fields[0], fields[1:]...) //nolint:gosec | ||
|
|
||
| // Write to std outputs + combined buffer | ||
| var outbuf bytes.Buffer | ||
| cmd.Stdout = io.MultiWriter(os.Stdout, &outbuf) | ||
| cmd.Stderr = io.MultiWriter(os.Stderr, &outbuf) | ||
|
|
||
| cmderr := cmd.Run() | ||
| cmdout := outbuf.Bytes() | ||
|
|
||
| return strings.TrimSpace(string(cmdout)), cmderr |
There was a problem hiding this comment.
Just confirming I think this means that we're going to write output directly to stdout and return it in this function where it will be logged again by the lock-exec CLI?
I think that might be fine... What do you think about creating a new function like RunDirectOutput (not sure of a good name) that has your change here and then does not return the output. So instead of returning the output it just sends it directly to stdout and then returns only the command exit code.
There was a problem hiding this comment.
I didn't want to change this function's interface so I set it up to do both.
This line logs it and adds the output as metadata to the log sent to dd. I was worried someone might have alerts or other things connected to that field.
I'm down to pick one or the other and drop that metadata if we think it's redundant though. Which would you prefer?
There was a problem hiding this comment.
I could also update that log to avoid the double-print
|
@ejeun this should get us to a place where calling Haven't confirmed if these logs will make it to DD correctly but I was going to check it on staging/prod. I didn't see any special connections set up in |
a1b859e to
86b7a57
Compare
Creates multiwriter with a single buffer (combined output) and std IO file descriptors
86b7a57 to
2abd386
Compare
|
I will merge this and tag a new version |
Writes command output directly to std IO and no longer returns a buffer.
https://www.loom.com/share/fc29e6dce02e43059e495169468caf0e