mirror of
				https://github.com/appleboy/drone-ssh.git
				synced 2025-10-29 00:51:15 +08:00 
			
		
		
		
	Customization of logger output destination
This commit is contained in:
		
							parent
							
								
									8bfc58f9d0
								
							
						
					
					
						commit
						6691360868
					
				
							
								
								
									
										1
									
								
								main.go
									
									
									
									
									
								
							
							
						
						
									
										1
									
								
								main.go
									
									
									
									
									
								
							| @ -211,6 +211,7 @@ func run(c *cli.Context) error { | |||||||
| 				Timeout:  c.Duration("proxy.timeout"), | 				Timeout:  c.Duration("proxy.timeout"), | ||||||
| 			}, | 			}, | ||||||
| 		}, | 		}, | ||||||
|  | 		Writer: os.Stdout, | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	return plugin.Exec() | 	return plugin.Exec() | ||||||
|  | |||||||
| @ -9,6 +9,7 @@ import ( | |||||||
| 	"time" | 	"time" | ||||||
| 
 | 
 | ||||||
| 	"github.com/appleboy/easyssh-proxy" | 	"github.com/appleboy/easyssh-proxy" | ||||||
|  | 	"io" | ||||||
| ) | ) | ||||||
| 
 | 
 | ||||||
| const ( | const ( | ||||||
| @ -40,6 +41,7 @@ type ( | |||||||
| 	// Plugin structure
 | 	// Plugin structure
 | ||||||
| 	Plugin struct { | 	Plugin struct { | ||||||
| 		Config Config | 		Config Config | ||||||
|  | 		Writer io.Writer | ||||||
| 	} | 	} | ||||||
| ) | ) | ||||||
| 
 | 
 | ||||||
| @ -121,10 +123,13 @@ func (p Plugin) exec(host string, wg *sync.WaitGroup, errChannel chan error) { | |||||||
| } | } | ||||||
| 
 | 
 | ||||||
| func (p Plugin) log(host string, message ...interface{}) { | func (p Plugin) log(host string, message ...interface{}) { | ||||||
|  | 	if p.Writer == nil { | ||||||
|  | 		p.Writer = os.Stdout | ||||||
|  | 	} | ||||||
| 	if count := len(p.Config.Host); count == 1 { | 	if count := len(p.Config.Host); count == 1 { | ||||||
| 		fmt.Printf("%s", fmt.Sprintln(message...)) | 		fmt.Fprintf(p.Writer, "%s", fmt.Sprintln(message...)) | ||||||
| 	} else { | 	} else { | ||||||
| 		fmt.Printf("%s: %s", host, fmt.Sprintln(message...)) | 		fmt.Fprintf(p.Writer, "%s: %s", host, fmt.Sprintln(message...)) | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user
	 Josh Komoroske
						Josh Komoroske