Poprawione logowanie

This commit is contained in:
Arkadiusz Rychliński
2022-11-08 11:36:07 +01:00
parent 3d21c4f1c2
commit abfa87b523
4 changed files with 37 additions and 18 deletions

View File

@ -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)