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` * `ERROR`
* `WARNING` * `WARNING`
* `AUDIT`
* `INFO` * `INFO`
* `DEBUG` * `DEBUG`
@ -184,6 +185,8 @@ For example:
``` ```
Output will be directed to the standard error stream, unless you specify the Output will be directed to the standard error stream, unless you specify the
path of a logfile via the `WLLVM_OUTPUT_FILE` environment variable. 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: 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 // But for the now, we just remove forbidden arguments
var success bool var success bool
var err error var err error
var linking = false var mode = "COMPILING"
// start afresh // start afresh
arguments := []string{} arguments := []string{}
// we are linking rather than compiling // we are linking rather than compiling
if len(pr.InputFiles) == 0 && len(pr.LinkArgs) > 0 { if len(pr.InputFiles) == 0 && len(pr.LinkArgs) > 0 {
linking = true mode = "LINKING"
if pr.IsLTO { if pr.IsLTO {
arguments = append(arguments, LLVMLtoLDFLAGS...) arguments = append(arguments, LLVMLtoLDFLAGS...)
} }
@ -339,11 +339,7 @@ func execCompile(compilerExecName string, pr ParserResult, wg *sync.WaitGroup, o
} else { } else {
arguments = append(arguments, pr.InputList...) arguments = append(arguments, pr.InputList...)
} }
if linking { LogAudit("%v %v %v", mode, compilerExecName, arguments)
LogInfo("LINKING with %v using %v", compilerExecName, arguments)
} else {
LogInfo("COMPILING with %v using %v", compilerExecName, arguments)
}
LogDebug("Calling execCmd(%v, %v)", compilerExecName, arguments) LogDebug("Calling execCmd(%v, %v)", compilerExecName, arguments)
success, err = execCmd(compilerExecName, arguments, "") success, err = execCmd(compilerExecName, arguments, "")
if !success { if !success {

View File

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