Remove trailing newline from wwlog

I noticed that some wwlog calls included a trailing newline, but others
did not. I tested both in isolation and discovered that the behavior was
consistent regardless of whether a trailing newline was included. I
further confirmed in code that wwlog appends a trailing newline
automatically if it is not present; so a trailing newline is unnecessary
in individual calls.

This commit removes trailing newlines from all calls to make them
consistent. It also replaces two calls to wwlog.Printf. (see #534)

Signed-off-by: Jonathon Anderson <janderson@ciq.co>
This commit is contained in:
Jonathon Anderson
2022-09-15 12:38:03 -06:00
parent fc39209fbb
commit 0b3e862bea
58 changed files with 327 additions and 327 deletions

View File

@@ -44,17 +44,17 @@ func InitStruct(nodeInfo node.NodeInfo) TemplateStruct {
var tstruct TemplateStruct
controller, err := warewulfconf.New()
if err != nil {
wwlog.Error("%s\n", err)
wwlog.Error("%s", err)
os.Exit(1)
}
nodeDB, err := node.New()
if err != nil {
wwlog.Error("%s\n", err)
wwlog.Error("%s", err)
os.Exit(1)
}
allNodes, err := nodeDB.FindAllNodes()
if err != nil {
wwlog.Error("%s\n", err)
wwlog.Error("%s", err)
os.Exit(1)
}
// init some convininence vars

View File

@@ -22,10 +22,10 @@ func templateFileInclude(inc string) string {
if !strings.HasPrefix(inc, "/") {
inc = path.Join(buildconfig.SYSCONFDIR(), "warewulf", inc)
}
wwlog.Debug("Including file into template: %s\n", inc)
wwlog.Debug("Including file into template: %s", inc)
content, err := ioutil.ReadFile(inc)
if err != nil {
wwlog.Verbose("Could not include file into template: %s\n", err)
wwlog.Verbose("Could not include file into template: %s", err)
}
return strings.TrimSuffix(string(content), "\n")
}
@@ -39,7 +39,7 @@ func templateFileBlock(inc string, abortStr string) (string, error) {
if !strings.HasPrefix(inc, "/") {
inc = path.Join(buildconfig.SYSCONFDIR(), "warewulf", inc)
}
wwlog.Debug("Including file block into template: %s\n", inc)
wwlog.Debug("Including file block into template: %s", inc)
readFile, err := os.Open(inc)
if err != nil {
return "", err
@@ -72,31 +72,31 @@ Reads a file relative to given container.
Templates in the file are no evaluated.
*/
func templateContainerFileInclude(containername string, filepath string) string {
wwlog.Verbose("Including file from Container into template: %s:%s\n", containername, filepath)
wwlog.Verbose("Including file from Container into template: %s:%s", containername, filepath)
if containername == "" {
wwlog.Warn("Container is not defined for node: %s\n", filepath)
wwlog.Warn("Container is not defined for node: %s", filepath)
return ""
}
if !container.ValidSource(containername) {
wwlog.Warn("Template requires file(s) from non-existant container: %s:%s\n", containername, filepath)
wwlog.Warn("Template requires file(s) from non-existant container: %s:%s", containername, filepath)
return ""
}
containerDir := container.RootFsDir(containername)
wwlog.Debug("Including file from container: %s:%s\n", containerDir, filepath)
wwlog.Debug("Including file from container: %s:%s", containerDir, filepath)
if !util.IsFile(path.Join(containerDir, filepath)) {
wwlog.Warn("Requested file from container does not exist: %s:%s\n", containername, filepath)
wwlog.Warn("Requested file from container does not exist: %s:%s", containername, filepath)
return ""
}
content, err := ioutil.ReadFile(path.Join(containerDir, filepath))
if err != nil {
wwlog.Error("Template include failed: %s\n", err)
wwlog.Error("Template include failed: %s", err)
}
return strings.TrimSuffix(string(content), "\n")
}

View File

@@ -200,11 +200,11 @@ func BuildOverlayIndir(nodeInfo node.NodeInfo, overlayNames []string, outputDir
return errors.Errorf("overlay names contains illegal characters: %v", overlayNames)
}
wwlog.Verbose("Processing node/overlay: %s/%s\n", nodeInfo.Id.Get(), strings.Join(overlayNames, "-"))
wwlog.Verbose("Processing node/overlay: %s/%s", nodeInfo.Id.Get(), strings.Join(overlayNames, "-"))
for _, overlayName := range overlayNames {
wwlog.Verbose("Building overlay %s for node %s in %s", overlayName, nodeInfo.Id.Get(), outputDir)
overlaySourceDir := OverlaySourceDir(overlayName)
wwlog.Debug("Starting to build overlay %s\nChanging directory to OverlayDir: %s\n", overlayName, overlaySourceDir)
wwlog.Debug("Starting to build overlay %s\nChanging directory to OverlayDir: %s", overlayName, overlaySourceDir)
err := os.Chdir(overlaySourceDir)
if err != nil {
return errors.Wrap(err, "could not change directory to overlay dir")
@@ -376,12 +376,12 @@ func RenderTemplateFile(fileName string, data TemplateStruct) (
"dec": func(i int) int { return i - 1 },
"file": func(str string) string { return fmt.Sprintf("{{ /* file \"%s\" */ }}", str) },
"abort": func() string {
wwlog.Debug("abort file called in %s\n", fileName)
wwlog.Debug("abort file called in %s", fileName)
writeFile = false
return ""
},
"nobackup": func() string {
wwlog.Debug("not backup for %s\n", fileName)
wwlog.Debug("not backup for %s", fileName)
backupFile = false
return ""
},