Replace all instances of wwlog.Printf

wwlog provides named loggers for each level, which requires
less code and is clearer than wwlog.Printf. The code has
included a mix of both, but this commit consolidates existing
code on the per-level functions.

Signed-off-by: Jonathon Anderson <janderson@ciq.co>
This commit is contained in:
Jonathon Anderson
2022-09-11 08:00:23 -06:00
parent 09c6986114
commit 22910958b5
56 changed files with 331 additions and 331 deletions

View File

@@ -11,40 +11,40 @@ import (
func CopyFile(src string, dst string) error {
wwlog.Printf(wwlog.DEBUG, "Copying '%s' to '%s'\n", src, dst)
wwlog.Debug("Copying '%s' to '%s'\n", src, dst)
// Open source file
srcFD, err := os.Open(src)
if err != nil {
wwlog.Printf(wwlog.ERROR, "Could not open source file %s: %s\n", src, err)
wwlog.Error("Could not open source file %s: %s\n", src, err)
return err
}
defer srcFD.Close()
srcInfo, err := srcFD.Stat()
if err != nil {
wwlog.Printf(wwlog.ERROR, "Could not stat source file %s: %s\n", src, err)
wwlog.Error("Could not stat source file %s: %s\n", src, err)
return err
}
dstFD, err := os.OpenFile(dst, os.O_RDWR|os.O_CREATE, srcInfo.Mode())
if err != nil {
wwlog.Printf(wwlog.ERROR, "Could not create destination file %s: %s\n", dst, err)
wwlog.Error("Could not create destination file %s: %s\n", dst, err)
return err
}
defer dstFD.Close()
bytes, err := io.Copy(dstFD, srcFD)
if err != nil {
wwlog.Printf(wwlog.ERROR, "File copy from %s to %s failed.\n %s\n", src, dst, err)
wwlog.Error("File copy from %s to %s failed.\n %s\n", src, dst, err)
return err
} else {
wwlog.Printf(wwlog.DEBUG, "Copied %d bytes from %s to %s.\n", bytes, src, dst)
wwlog.Debug("Copied %d bytes from %s to %s.\n", bytes, src, dst)
}
err = CopyUIDGID(src, dst)
if err != nil {
wwlog.Printf(wwlog.ERROR, "Ownership copy from %s to %s failed.\n %s\n", src, dst, err)
wwlog.Error("Ownership copy from %s to %s failed.\n %s\n", src, dst, err)
return err
}
return nil
@@ -54,7 +54,7 @@ func SafeCopyFile(src string, dst string) error {
var err error
// Don't overwrite existing files -- should add force overwrite switch
if _, err = os.Stat(dst); err == nil {
wwlog.Printf(wwlog.DEBUG, "Destination file %s exists.\n", dst)
wwlog.Debug("Destination file %s exists.\n", dst)
} else {
err = CopyFile(src, dst)
}
@@ -68,7 +68,7 @@ func CopyFiles(source string, dest string) error {
}
if info.IsDir() {
wwlog.Printf(wwlog.DEBUG, "Creating directory: %s\n", location)
wwlog.Debug("Creating directory: %s\n", location)
info, err := os.Stat(source)
if err != nil {
return err
@@ -84,7 +84,7 @@ func CopyFiles(source string, dest string) error {
}
} else {
wwlog.Printf(wwlog.DEBUG, "Writing file: %s\n", location)
wwlog.Debug("Writing file: %s\n", location)
err := CopyFile(location, path.Join(dest, location))
if err != nil {