Poprawione logowanie
This commit is contained in:
10
psql/psql.go
10
psql/psql.go
@ -2,6 +2,7 @@ package psql
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"multisql/cfg"
|
||||
"os"
|
||||
"os/exec"
|
||||
@ -16,6 +17,7 @@ type Instance struct {
|
||||
passfile string
|
||||
psqlExe string
|
||||
conn cfg.Connection
|
||||
verbose bool
|
||||
}
|
||||
|
||||
type Result struct {
|
||||
@ -23,7 +25,7 @@ type Result struct {
|
||||
Err error
|
||||
}
|
||||
|
||||
func Create(passfile string, outdir string, scripts []string, conn cfg.Connection, psqlExe string) (instnace Instance) {
|
||||
func Create(passfile string, outdir string, scripts []string, conn cfg.Connection, psqlExe string, verbose bool) (instnace Instance) {
|
||||
|
||||
instnace = Instance{
|
||||
outdir: outdir,
|
||||
@ -31,6 +33,7 @@ func Create(passfile string, outdir string, scripts []string, conn cfg.Connectio
|
||||
passfile: passfile,
|
||||
conn: conn,
|
||||
psqlExe: psqlExe,
|
||||
verbose: verbose,
|
||||
}
|
||||
return instnace
|
||||
}
|
||||
@ -62,7 +65,6 @@ func (self Instance) Exec(result chan<- Result) {
|
||||
continue
|
||||
}
|
||||
err = self.cmdPsql(outdir, connString, scr, absPassFile)
|
||||
fmt.Println()
|
||||
result <- Result{
|
||||
Script: scr,
|
||||
Err: err,
|
||||
@ -116,7 +118,9 @@ func (self Instance) cmdPsql(outdir string, connString string, script string, pa
|
||||
}
|
||||
|
||||
|
||||
fmt.Println("Uruchamiam", cmd.String())
|
||||
if self.verbose {
|
||||
log.Printf("Uruchamiam %s", cmd.String())
|
||||
}
|
||||
err = cmd.Run()
|
||||
if err != nil {
|
||||
return fmt.Errorf("Błąd uruchamiania psql: %v", err)
|
||||
|
Reference in New Issue
Block a user