mirror of
https://github.com/cloudflare/cloudflared.git
synced 2025-07-27 19:19:57 +00:00
TUN-8783: fix log collectors for the diagnostic procedure
## Summary * The host log collector now verifies if the OS is linux and has systemd if so it will use journalctl to get the logs * In linux systems docker will write the output of the command logs to the stderr therefore the function that handles the execution of the process will copy both the contents of stdout and stderr; this also affect the k8s collector Closes TUN-8783
This commit is contained in:
@@ -12,7 +12,16 @@ func PipeCommandOutputToFile(command *exec.Cmd, outputHandle *os.File) (*LogInfo
|
||||
stdoutReader, err := command.StdoutPipe()
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf(
|
||||
"error retrieving output from command '%s': %w",
|
||||
"error retrieving stdout from command '%s': %w",
|
||||
command.String(),
|
||||
err,
|
||||
)
|
||||
}
|
||||
|
||||
stderrReader, err := command.StderrPipe()
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf(
|
||||
"error retrieving stderr from command '%s': %w",
|
||||
command.String(),
|
||||
err,
|
||||
)
|
||||
@@ -29,7 +38,17 @@ func PipeCommandOutputToFile(command *exec.Cmd, outputHandle *os.File) (*LogInfo
|
||||
_, err = io.Copy(outputHandle, stdoutReader)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf(
|
||||
"error copying output from %s to file %s: %w",
|
||||
"error copying stdout from %s to file %s: %w",
|
||||
command.String(),
|
||||
outputHandle.Name(),
|
||||
err,
|
||||
)
|
||||
}
|
||||
|
||||
_, err = io.Copy(outputHandle, stderrReader)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf(
|
||||
"error copying stderr from %s to file %s: %w",
|
||||
command.String(),
|
||||
outputHandle.Name(),
|
||||
err,
|
||||
|
Reference in New Issue
Block a user