Skip to content

Commit

Permalink
Merge pull request #105 from chapsuk/logger
Browse files Browse the repository at this point in the history
Added logger interface and SetLogger func for redefine package output
  • Loading branch information
VojtechVitek authored Apr 30, 2018
2 parents b0454a4 + 1cebce8 commit f0b1c6f
Show file tree
Hide file tree
Showing 11 changed files with 23 additions and 10 deletions.
2 changes: 1 addition & 1 deletion cmd/goose/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func main() {
switch driver {
case "redshift":
driver = "postgres"
case "tidb":
case "tidb":
driver = "mysql"
}

Expand Down
1 change: 0 additions & 1 deletion create.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package goose
import (
"database/sql"
"fmt"
"log"
"os"
"path/filepath"
"text/template"
Expand Down
1 change: 0 additions & 1 deletion down.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package goose
import (
"database/sql"
"fmt"
"log"
)

// Down rolls back a single migration from the current version.
Expand Down
22 changes: 22 additions & 0 deletions log.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package goose

import (
std "log"
"os"
)

var log Logger = std.New(os.Stderr, "", std.LstdFlags)

// Logger is standart logger interface
type Logger interface {
Fatal(v ...interface{})
Fatalf(format string, v ...interface{})
Print(v ...interface{})
Println(v ...interface{})
Printf(format string, v ...interface{})
}

// SetLogger sets the logger for package output
func SetLogger(l Logger) {
log = l
}
1 change: 0 additions & 1 deletion migrate.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"database/sql"
"errors"
"fmt"
"log"
"os"
"path/filepath"
"runtime"
Expand Down
1 change: 0 additions & 1 deletion migration.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"database/sql"
"errors"
"fmt"
"log"
"path/filepath"
"strconv"
"strings"
Expand Down
1 change: 0 additions & 1 deletion migration_sql.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"bytes"
"database/sql"
"io"
"log"
"os"
"strings"
)
Expand Down
1 change: 0 additions & 1 deletion reset.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package goose

import (
"database/sql"
"log"
"sort"
)

Expand Down
1 change: 0 additions & 1 deletion status.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package goose
import (
"database/sql"
"fmt"
"log"
"path/filepath"
"time"
)
Expand Down
1 change: 0 additions & 1 deletion up.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package goose

import (
"database/sql"
"log"
)

// UpTo migrates up to a specific version.
Expand Down
1 change: 0 additions & 1 deletion version.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package goose

import (
"database/sql"
"log"
)

// Version prints the current version of the database.
Expand Down

0 comments on commit f0b1c6f

Please sign in to comment.