Skip to content

Commit ede7a49

Browse files
committed
Added an new AUDIT logging level betwix WARNING and INFO that just logs the calls.
1 parent ea18e03 commit ede7a49

File tree

3 files changed

+13
-8
lines changed

3 files changed

+13
-8
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,7 @@ variable to one of the following levels:
175175

176176
* `ERROR`
177177
* `WARNING`
178+
* `AUDIT`
178179
* `INFO`
179180
* `DEBUG`
180181

@@ -184,6 +185,8 @@ For example:
184185
```
185186
Output will be directed to the standard error stream, unless you specify the
186187
path of a logfile via the `WLLVM_OUTPUT_FILE` environment variable.
188+
The `AUDIT` level, new in 2022, logs only the calls to the compiler, and indicates
189+
whether each call is *compiling* or *linking*, the compiler used, and the arguments provided.
187190

188191
For example:
189192
```

shared/compiler.go

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -312,12 +312,12 @@ func execCompile(compilerExecName string, pr ParserResult, wg *sync.WaitGroup, o
312312
// But for the now, we just remove forbidden arguments
313313
var success bool
314314
var err error
315-
var linking = false
315+
var mode = "COMPILING"
316316
// start afresh
317317
arguments := []string{}
318318
// we are linking rather than compiling
319319
if len(pr.InputFiles) == 0 && len(pr.LinkArgs) > 0 {
320-
linking = true
320+
mode = "LINKING"
321321
if pr.IsLTO {
322322
arguments = append(arguments, LLVMLtoLDFLAGS...)
323323
}
@@ -339,11 +339,7 @@ func execCompile(compilerExecName string, pr ParserResult, wg *sync.WaitGroup, o
339339
} else {
340340
arguments = append(arguments, pr.InputList...)
341341
}
342-
if linking {
343-
LogInfo("LINKING with %v using %v", compilerExecName, arguments)
344-
} else {
345-
LogInfo("COMPILING with %v using %v", compilerExecName, arguments)
346-
}
342+
LogAudit("%v %v %v", mode, compilerExecName, arguments)
347343
LogDebug("Calling execCmd(%v, %v)", compilerExecName, arguments)
348344
success, err = execCmd(compilerExecName, arguments, "")
349345
if !success {

shared/logging.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ import (
4242
const (
4343
errorV = iota
4444
warningV
45+
auditV
4546
infoV
4647
debugV
4748
)
@@ -50,18 +51,20 @@ const (
5051
var loggingLevels = map[string]int{
5152
"ERROR": errorV,
5253
"WARNING": warningV,
54+
"AUDIT": auditV,
5355
"INFO": infoV,
5456
"DEBUG": debugV,
5557
}
5658

5759
var loggingPrefixes = map[int]string{
5860
errorV: "ERROR:",
5961
warningV: "WARNING:",
62+
auditV: "AUDIT:",
6063
infoV: "INFO:",
6164
debugV: "DEBUG:",
6265
}
6366

64-
// loggingLevel is the user configured level of logging: ERROR, WARNING, INFO, DEBUG
67+
// loggingLevel is the user configured level of logging: ERROR, WARNING, AUDIT, INFO, DEBUG
6568
var loggingLevel = warningV
6669

6770
// loggingFilePointer is where the logging is streamed too.
@@ -114,6 +117,9 @@ var LogInfo = makeLogger(infoV)
114117
// LogWarning logs to the configured stream if the logging level is WARNING or lower.
115118
var LogWarning = makeLogger(warningV)
116119

120+
// LogAudit logs to the configured stream if the logging level is AUDIT or lower.
121+
var LogAudit = makeLogger(auditV)
122+
117123
// LogError logs to the configured stream if the logging level is ERROR or lower.
118124
var LogError = makeLogger(errorV)
119125

0 commit comments

Comments
 (0)