Skip to content

Commit

Permalink
chore(misconf): Clean up iac logger (#6642)
Browse files Browse the repository at this point in the history
  • Loading branch information
simar7 committed May 8, 2024
1 parent 4eae37c commit fe5d40e
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 63 deletions.
5 changes: 0 additions & 5 deletions pkg/iac/debug/cgo_disabled.go

This file was deleted.

5 changes: 0 additions & 5 deletions pkg/iac/debug/cgo_enabled.go

This file was deleted.

53 changes: 0 additions & 53 deletions pkg/iac/debug/debug.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@ package debug
import (
"fmt"
"io"
"os"
"path/filepath"
"runtime"
"strings"
"time"
)
Expand Down Expand Up @@ -39,53 +36,3 @@ func (l *Logger) Log(format string, args ...interface{}) {
line := fmt.Sprintf("%s %-32s %s\n", time.Now().Format(timeFormat), l.prefix, message)
_, _ = l.writer.Write([]byte(line))
}

func LogSystemInfo(w io.Writer, appVersion string) {
if w == nil {
return
}
sys := New(w, "system", "info")
var appName string
if path, err := os.Executable(); err != nil {
if len(os.Args) > 0 {
appName = os.Args[0]
}
} else {
appName = filepath.Base(path)
}

wd, _ := os.Getwd()
hostname, _ := os.Hostname()

var inDocker bool
if _, err := os.Stat("/.dockerenv"); err == nil || !os.IsNotExist(err) {
inDocker = true
}

var kernelInfo string
if data, err := os.ReadFile("/proc/version"); err == nil {
kernelInfo = strings.TrimSpace(string(data))
}

sys.Log("APP %s", appName)
sys.Log("VERSION %s", appVersion)
sys.Log("OS %s", runtime.GOOS)
sys.Log("ARCH %s", runtime.GOARCH)
sys.Log("KERNEL %s", kernelInfo)
sys.Log("TERM %s", os.Getenv("TERM"))
sys.Log("SHELL %s", os.Getenv("SHELL"))
sys.Log("GOVERSION %s", runtime.Version())
sys.Log("GOROOT %s", runtime.GOROOT())
sys.Log("CGO %t", cgoEnabled)
sys.Log("CPUCOUNT %d", runtime.NumCPU())
sys.Log("MAXPROCS %d", runtime.GOMAXPROCS(0))
sys.Log("WORKDIR %s", wd)
sys.Log("UID %d", os.Getuid())
sys.Log("EUID %d", os.Geteuid())
sys.Log("DOCKER %t", inDocker)
sys.Log("CI %t", os.Getenv("CI") != "")
sys.Log("HOSTNAME %s", hostname)
sys.Log("TEMP %s", os.TempDir())
sys.Log("PATHSEP %c", filepath.Separator)
sys.Log("CMD %s", strings.Join(os.Args, " "))
}

0 comments on commit fe5d40e

Please sign in to comment.