mirror of
https://github.com/opentofu/opentofu.git
synced 2025-01-16 03:32:54 -06:00
Small update/fix to properly clean ANSI going to the logfile...
This commit is contained in:
parent
60984b2da2
commit
4a99cf9e9f
@ -9,6 +9,7 @@ import (
|
||||
"log"
|
||||
"os"
|
||||
"path"
|
||||
"regexp"
|
||||
"strings"
|
||||
"text/template"
|
||||
"time"
|
||||
@ -269,7 +270,13 @@ func (p *Provisioner) Output(output string) {
|
||||
}
|
||||
defer f.Close()
|
||||
|
||||
// These steps are needed to remove any ANSI escape codes used to colorize
|
||||
// the output and to make sure we have proper line endings before writing
|
||||
// the string to the logfile.
|
||||
re := regexp.MustCompile(`\x1b\[[0-9;]+m`)
|
||||
output = re.ReplaceAllString(output, "")
|
||||
output = strings.Replace(output, "\r", "\n", -1)
|
||||
|
||||
if _, err := f.WriteString(output); err != nil {
|
||||
log.Printf("Error writing output to logfile %s: %v", logFile, err)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user