Added an new AUDIT logging level betwix WARNING and INFO that just logs the calls.

This commit is contained in:
Ian A. Mason 2022-09-07 11:33:38 -07:00
parent ea18e036f8
commit ede7a49a98
3 changed files with 13 additions and 8 deletions

View File

@ -175,6 +175,7 @@ variable to one of the following levels:
* `ERROR`
* `WARNING`
* `AUDIT`
* `INFO`
* `DEBUG`
@ -184,6 +185,8 @@ For example:
```
Output will be directed to the standard error stream, unless you specify the
path of a logfile via the `WLLVM_OUTPUT_FILE` environment variable.
The `AUDIT` level, new in 2022, logs only the calls to the compiler, and indicates
whether each call is *compiling* or *linking*, the compiler used, and the arguments provided.
For example:
```

View File

@ -312,12 +312,12 @@ func execCompile(compilerExecName string, pr ParserResult, wg *sync.WaitGroup, o
// But for the now, we just remove forbidden arguments
var success bool
var err error
var linking = false
var mode = "COMPILING"
// start afresh
arguments := []string{}
// we are linking rather than compiling
if len(pr.InputFiles) == 0 && len(pr.LinkArgs) > 0 {
linking = true
mode = "LINKING"
if pr.IsLTO {
arguments = append(arguments, LLVMLtoLDFLAGS...)
}
@ -339,11 +339,7 @@ func execCompile(compilerExecName string, pr ParserResult, wg *sync.WaitGroup, o
} else {
arguments = append(arguments, pr.InputList...)
}
if linking {
LogInfo("LINKING with %v using %v", compilerExecName, arguments)
} else {
LogInfo("COMPILING with %v using %v", compilerExecName, arguments)
}
LogAudit("%v %v %v", mode, compilerExecName, arguments)
LogDebug("Calling execCmd(%v, %v)", compilerExecName, arguments)
success, err = execCmd(compilerExecName, arguments, "")
if !success {

View File

@ -42,6 +42,7 @@ import (
const (
errorV = iota
warningV
auditV
infoV
debugV
)
@ -50,6 +51,7 @@ const (
var loggingLevels = map[string]int{
"ERROR": errorV,
"WARNING": warningV,
"AUDIT": auditV,
"INFO": infoV,
"DEBUG": debugV,
}
@ -57,11 +59,12 @@ var loggingLevels = map[string]int{
var loggingPrefixes = map[int]string{
errorV: "ERROR:",
warningV: "WARNING:",
auditV: "AUDIT:",
infoV: "INFO:",
debugV: "DEBUG:",
}
// loggingLevel is the user configured level of logging: ERROR, WARNING, INFO, DEBUG
// loggingLevel is the user configured level of logging: ERROR, WARNING, AUDIT, INFO, DEBUG
var loggingLevel = warningV
// loggingFilePointer is where the logging is streamed too.
@ -114,6 +117,9 @@ var LogInfo = makeLogger(infoV)
// LogWarning logs to the configured stream if the logging level is WARNING or lower.
var LogWarning = makeLogger(warningV)
// LogAudit logs to the configured stream if the logging level is AUDIT or lower.
var LogAudit = makeLogger(auditV)
// LogError logs to the configured stream if the logging level is ERROR or lower.
var LogError = makeLogger(errorV)