This repository was archived by the owner on Feb 15, 2024. It is now read-only.

Description
Example:
+ myFuncName := caller.GetFuncName()
log.Debugf(
- "Config file %q exists, attempting to open it",
+ "%s: Config file %q exists, attempting to open it",
+ myFuncName,
sanitizedFilePath,
)
// use direct function call here instead of our variable to comply
// with gosec linting rules
fh, err := os.Open(filepath.Clean(config.ConfigFile()))
if err != nil {
- return nil, fmt.Errorf("unable to open config file: %v", err)
+ return nil, fmt.Errorf(
+ "%s: unable to open config file: %v",
+ myFuncName,
+ err,
+ )
The exception might be where including the function name adds visual noise for output meant to be directly read/acted upon. That said, our target audience is a sysadmin who should be familiar with (or at least appreciate) the verbose nature of the log/error messages.
I've been making these changes as I've resolved recent linting issues (and likely before that), but spinning this issue off as a reminder to continue the work going forward.