Skip to content

Commit

Permalink
Added an new AUDIT logging level betwix WARNING and INFO that just lo…
Browse files Browse the repository at this point in the history
…gs the calls.
  • Loading branch information
ianamason committed Sep 7, 2022
1 parent ea18e03 commit ede7a49
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 8 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ variable to one of the following levels:

* `ERROR`
* `WARNING`
* `AUDIT`
* `INFO`
* `DEBUG`

Expand All @@ -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:
```
Expand Down
10 changes: 3 additions & 7 deletions shared/compiler.go
Original file line number Diff line number Diff line change
Expand Up @@ -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...)
}
Expand All @@ -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 {
Expand Down
8 changes: 7 additions & 1 deletion shared/logging.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ import (
const (
errorV = iota
warningV
auditV
infoV
debugV
)
Expand All @@ -50,18 +51,20 @@ const (
var loggingLevels = map[string]int{
"ERROR": errorV,
"WARNING": warningV,
"AUDIT": auditV,
"INFO": infoV,
"DEBUG": debugV,
}

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.
Expand Down Expand Up @@ -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)

Expand Down

0 comments on commit ede7a49

Please sign in to comment.