67 lines
2.1 KiB
Go
67 lines
2.1 KiB
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"log"
|
|
)
|
|
|
|
// LogInfo logs an informational message
|
|
func LogInfo(format string, args ...interface{}) {
|
|
log.Printf(format, args...)
|
|
}
|
|
|
|
// LogSource logs a message about a source file/path with proper coloring
|
|
func LogSource(format string, args ...interface{}) {
|
|
message := fmt.Sprintf(format, args...)
|
|
log.Printf("%s%s%s", SourceColor, message, DefaultColor)
|
|
}
|
|
|
|
// LogTarget logs a message about a target file/path with proper coloring
|
|
func LogTarget(format string, args ...interface{}) {
|
|
message := fmt.Sprintf(format, args...)
|
|
log.Printf("%s%s%s", TargetColor, message, DefaultColor)
|
|
}
|
|
|
|
// LogPath logs a message about a path with proper coloring
|
|
func LogPath(format string, args ...interface{}) {
|
|
message := fmt.Sprintf(format, args...)
|
|
log.Printf("%s%s%s", PathColor, message, DefaultColor)
|
|
}
|
|
|
|
// LogImportant logs a message that needs attention with proper coloring
|
|
func LogImportant(format string, args ...interface{}) {
|
|
message := fmt.Sprintf(format, args...)
|
|
log.Printf("%s%s%s", ImportantColor, message, DefaultColor)
|
|
}
|
|
|
|
// LogError logs an error message with proper coloring that won't be cut off
|
|
func LogError(format string, args ...interface{}) {
|
|
message := fmt.Sprintf(format, args...)
|
|
log.Printf("%s%s%s", ErrorColor, message, DefaultColor)
|
|
// Make sure we're properly resetting before applying error color to avoid cutoffs
|
|
log.Printf("%s%s%s", ErrorColor, fmt.Sprintf(format, args...), DefaultColor)
|
|
}
|
|
|
|
// FormatSourcePath formats a source path with proper coloring
|
|
func FormatSourcePath(path string) string {
|
|
return fmt.Sprintf("%s%s%s", SourceColor, path, DefaultColor)
|
|
}
|
|
|
|
// FormatTargetPath formats a target path with proper coloring
|
|
func FormatTargetPath(path string) string {
|
|
return fmt.Sprintf("%s%s%s", TargetColor, path, DefaultColor)
|
|
}
|
|
|
|
// FormatPathValue formats a path value with proper coloring
|
|
func FormatPathValue(path string) string {
|
|
return fmt.Sprintf("%s%s%s", PathColor, path, DefaultColor)
|
|
}
|
|
|
|
// FormatErrorValue formats an error value with proper coloring
|
|
func FormatErrorValue(err error) string {
|
|
if err == nil {
|
|
return ""
|
|
}
|
|
return fmt.Sprintf("%s%v%s", ErrorColor, err, DefaultColor)
|
|
}
|