From ede7a49a989ac04907549047240d2f973f83af5f Mon Sep 17 00:00:00 2001 From: "Ian A. Mason" Date: Wed, 7 Sep 2022 11:33:38 -0700 Subject: [PATCH] Added an new AUDIT logging level betwix WARNING and INFO that just logs the calls. --- README.md | 3 +++ shared/compiler.go | 10 +++------- shared/logging.go | 8 +++++++- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 0132189..909000c 100644 --- a/README.md +++ b/README.md @@ -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: ``` diff --git a/shared/compiler.go b/shared/compiler.go index 3f604a2..3dab892 100644 --- a/shared/compiler.go +++ b/shared/compiler.go @@ -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 { diff --git a/shared/logging.go b/shared/logging.go index ba2e3df..0ffafe3 100644 --- a/shared/logging.go +++ b/shared/logging.go @@ -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)