Skip to content

Commit

Permalink
refactor: enhance logging in writeFiles function
Browse files Browse the repository at this point in the history
- Updated logging in the writeFiles function to include a secondary prefix "Setup" for better context during file writing operations.
- Changed log message format to "echo \"%s\" > \"%s\"" for clarity, improving the overall logging output during the execution of the file write command.
  • Loading branch information
ryan-gang committed Jan 14, 2025
1 parent a019e29 commit 22cb555
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion internal/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,10 @@ func writeFile(path string, content string) error {
// writeFiles writes a list of files to the given paths with the given contents
func writeFiles(paths []string, contents []string, logger *logger.Logger) error {
for i, content := range contents {
logger.Infof("Writing file \"%s\" with content \"%s\"", paths[i], strings.TrimRight(content, "\n"))
logger.UpdateSecondaryPrefix("Setup")
logger.Infof("echo \"%s\" > \"%s\"", strings.TrimRight(content, "\n"), paths[i])
logger.ResetSecondaryPrefix()

if err := writeFile(paths[i], content); err != nil {
logger.Errorf("Error writing file %s: %v", paths[i], err)
return err
Expand Down

0 comments on commit 22cb555

Please sign in to comment.