Skip to content
This repository has been archived by the owner on Feb 15, 2024. It is now read-only.

Complete the process of using myFuncName in all log messages #124

Open
atc0005 opened this issue Jul 23, 2020 · 1 comment
Open

Complete the process of using myFuncName in all log messages #124

atc0005 opened this issue Jul 23, 2020 · 1 comment
Assignees
Labels
enhancement New feature or request logging
Milestone

Comments

@atc0005
Copy link
Owner

atc0005 commented Jul 23, 2020

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.

@atc0005 atc0005 added enhancement New feature or request logging labels Jul 23, 2020
@atc0005 atc0005 added this to the Future milestone Jul 23, 2020
@atc0005 atc0005 self-assigned this Jul 23, 2020
@atc0005
Copy link
Owner Author

atc0005 commented Jul 23, 2020

See also GH-119 and f2aafe9 specifically.

atc0005 added a commit that referenced this issue Jul 23, 2020
Complete the work for this func that was started with commit
f2aafe9 for GH-104

- refs GH-104
- refs GH-124
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request logging
Projects
None yet
Development

No branches or pull requests

1 participant