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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to set log level without writing to file #436

Open
wandergeek opened this issue Jan 25, 2024 · 1 comment
Open

Unable to set log level without writing to file #436

wandergeek opened this issue Jan 25, 2024 · 1 comment

Comments

@wandergeek
Copy link

wandergeek commented Jan 25, 2024

Hey there legends! 馃憢

I'm trying to set TF_LOG using tf.SetLog("TRACE") and I am not getting any TRACE logging unless I also set the TF_LOG_PATH. Looking closer at the code, it looks like this is expected behavior? https://github.com/hashicorp/terraform-exec/blob/main/tfexec/cmd.go#L154-L166

Is there a way I can get TRACE logging without having to set the log path as well?

Cheers,
Nick

@wandergeek
Copy link
Author

Even weirder, when I use SetLogPath to set the logging destination file, I don't actually get a file out. Taking a stab in the dark, maybe this has something to do with overwriting the logging destinations?

// Read stdout / stderr logs from pipe instead of setting cmd.Stdout and
// cmd.Stderr because it can cause hanging when killing the command
// https://github.com/golang/go/issues/23019
stdoutWriter := mergeWriters(cmd.Stdout, tf.stdout)
stderrWriter := mergeWriters(tf.stderr, &errBuf)
cmd.Stderr = nil
cmd.Stdout = nil
stdoutPipe, err := cmd.StdoutPipe()
if err != nil {
return err
}
stderrPipe, err := cmd.StderrPipe()
if err != nil {
return err
}

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

No branches or pull requests

1 participant