Add LogSuccess

This commit is contained in:
2025-03-11 21:37:55 +01:00
parent 5a2520e3b1
commit 3a5a333c62
2 changed files with 9 additions and 1 deletions

View File

@@ -74,6 +74,7 @@ func (instruction *LinkInstruction) Undo() {
LogError("could not remove symlink at %s; err: %v", LogError("could not remove symlink at %s; err: %v",
FormatTargetPath(instruction.Target), err) FormatTargetPath(instruction.Target), err)
} }
LogSuccess("Removed symlink at %s", FormatTargetPath(instruction.Target))
} else { } else {
LogInfo("%s is not a symlink, skipping", FormatTargetPath(instruction.Target)) LogInfo("%s is not a symlink, skipping", FormatTargetPath(instruction.Target))
} }
@@ -254,7 +255,7 @@ func (instruction *LinkInstruction) RunAsync(status chan (error)) {
err) err)
return return
} }
LogInfo("Created symlink between %s and %s", LogSuccess("Created symlink between %s and %s",
FormatSourcePath(instruction.Source), FormatSourcePath(instruction.Source),
FormatTargetPath(instruction.Target)) FormatTargetPath(instruction.Target))

View File

@@ -14,6 +14,7 @@ const (
TargetPrefix = "TARGET" TargetPrefix = "TARGET"
PathPrefix = "PATH" PathPrefix = "PATH"
ImportantPrefix = "IMPORTANT" ImportantPrefix = "IMPORTANT"
SuccessPrefix = "DONE"
) )
// LogInfo logs an informational message // LogInfo logs an informational message
@@ -22,6 +23,12 @@ func LogInfo(format string, args ...interface{}) {
log.Printf("%s[%s]%s %s", BGreen, InfoPrefix, Reset, message) log.Printf("%s[%s]%s %s", BGreen, InfoPrefix, Reset, message)
} }
// LogSuccess logs a success message
func LogSuccess(format string, args ...interface{}) {
message := fmt.Sprintf(format, args...)
log.Printf("%s%s[%s]%s %s", BBlue, On_Blue, SuccessPrefix, Reset, message)
}
// LogSource logs a message about a source file/path with proper coloring // LogSource logs a message about a source file/path with proper coloring
func LogSource(format string, args ...interface{}) { func LogSource(format string, args ...interface{}) {
message := fmt.Sprintf(format, args...) message := fmt.Sprintf(format, args...)