In preparation for parallelism, emit all log lines prefixed by hostname
This commit is contained in:
14
src/main.go
14
src/main.go
@ -64,6 +64,8 @@ func main() {
|
||||
keyFile = findDefaultSSHKey()
|
||||
if keyFile == "" {
|
||||
log.Fatal("No SSH key found and no password provided")
|
||||
} else {
|
||||
fmt.Printf("Using SSH key: %s\n", keyFile)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -95,7 +97,7 @@ func main() {
|
||||
totalCount := len(devicesToProcess)
|
||||
|
||||
for hostname, deviceConfig := range devicesToProcess {
|
||||
fmt.Printf("\nProcessing device: %s (type: %s)\n", hostname, deviceConfig.Type)
|
||||
fmt.Printf("\n%s: Processing device (type: %s)\n", hostname, deviceConfig.Type)
|
||||
|
||||
user := deviceConfig.User
|
||||
commands := deviceConfig.Commands
|
||||
@ -111,12 +113,12 @@ func main() {
|
||||
}
|
||||
|
||||
if user == "" {
|
||||
fmt.Printf("No user specified for %s, skipping\n", hostname)
|
||||
fmt.Printf("%s: No user specified, skipping\n", hostname)
|
||||
continue
|
||||
}
|
||||
|
||||
if len(commands) == 0 {
|
||||
fmt.Printf("No commands specified for %s, skipping\n", hostname)
|
||||
fmt.Printf("%s: No commands specified, skipping\n", hostname)
|
||||
continue
|
||||
}
|
||||
|
||||
@ -125,7 +127,7 @@ func main() {
|
||||
|
||||
// Connect and backup
|
||||
if err := backup.Connect(); err != nil {
|
||||
fmt.Printf("Failed to connect to %s: %v\n", hostname, err)
|
||||
fmt.Printf("%s: Failed to connect: %v\n", hostname, err)
|
||||
continue
|
||||
}
|
||||
|
||||
@ -133,9 +135,9 @@ func main() {
|
||||
backup.Disconnect()
|
||||
|
||||
if err != nil {
|
||||
fmt.Printf("Backup failed for %s: %v\n", hostname, err)
|
||||
fmt.Printf("%s: Backup failed: %v\n", hostname, err)
|
||||
} else {
|
||||
fmt.Printf("Backup completed for %s\n", hostname)
|
||||
fmt.Printf("%s: Backup completed\n", hostname)
|
||||
successCount++
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user