mirror of https://github.com/pressly/goose.git
refactor: trim down the logger interface (#559)
parent
06ff963c97
commit
9ba828de25
|
@ -22,11 +22,11 @@ const (
|
|||
|
||||
func TestMain(m *testing.M) {
|
||||
if runtime.GOOS == "windows" {
|
||||
log.Fatal("this test is not supported on Windows")
|
||||
log.Fatalf("this test is not supported on Windows")
|
||||
}
|
||||
dir, err := os.Getwd()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
log.Fatalf("%v", err)
|
||||
}
|
||||
args := []string{
|
||||
"build",
|
||||
|
|
9
log.go
9
log.go
|
@ -8,10 +8,7 @@ var log Logger = &stdLogger{}
|
|||
|
||||
// Logger is standard logger interface
|
||||
type Logger interface {
|
||||
Fatal(v ...interface{})
|
||||
Fatalf(format string, v ...interface{})
|
||||
Print(v ...interface{})
|
||||
Println(v ...interface{})
|
||||
Printf(format string, v ...interface{})
|
||||
}
|
||||
|
||||
|
@ -23,10 +20,7 @@ func SetLogger(l Logger) {
|
|||
// stdLogger is a default logger that outputs to a stdlib's log.std logger.
|
||||
type stdLogger struct{}
|
||||
|
||||
func (*stdLogger) Fatal(v ...interface{}) { std.Fatal(v...) }
|
||||
func (*stdLogger) Fatalf(format string, v ...interface{}) { std.Fatalf(format, v...) }
|
||||
func (*stdLogger) Print(v ...interface{}) { std.Print(v...) }
|
||||
func (*stdLogger) Println(v ...interface{}) { std.Println(v...) }
|
||||
func (*stdLogger) Printf(format string, v ...interface{}) { std.Printf(format, v...) }
|
||||
|
||||
// NopLogger returns a logger that discards all logged output.
|
||||
|
@ -38,8 +32,5 @@ type nopLogger struct{}
|
|||
|
||||
var _ Logger = (*nopLogger)(nil)
|
||||
|
||||
func (*nopLogger) Fatal(v ...interface{}) {}
|
||||
func (*nopLogger) Fatalf(format string, v ...interface{}) {}
|
||||
func (*nopLogger) Print(v ...interface{}) {}
|
||||
func (*nopLogger) Println(v ...interface{}) {}
|
||||
func (*nopLogger) Printf(format string, v ...interface{}) {}
|
||||
|
|
|
@ -26,8 +26,8 @@ func StatusContext(ctx context.Context, db *sql.DB, dir string, opts ...OptionsF
|
|||
return fmt.Errorf("failed to collect migrations: %w", err)
|
||||
}
|
||||
if option.noVersioning {
|
||||
log.Println(" Applied At Migration")
|
||||
log.Println(" =======================================")
|
||||
log.Printf(" Applied At Migration\n")
|
||||
log.Printf(" =======================================\n")
|
||||
for _, current := range migrations {
|
||||
log.Printf(" %-24s -- %v\n", "no versioning", filepath.Base(current.Source))
|
||||
}
|
||||
|
@ -39,8 +39,8 @@ func StatusContext(ctx context.Context, db *sql.DB, dir string, opts ...OptionsF
|
|||
return fmt.Errorf("failed to ensure DB version: %w", err)
|
||||
}
|
||||
|
||||
log.Println(" Applied At Migration")
|
||||
log.Println(" =======================================")
|
||||
log.Printf(" Applied At Migration\n")
|
||||
log.Printf(" =======================================\n")
|
||||
for _, migration := range migrations {
|
||||
if err := printMigrationStatus(ctx, db, migration.Version, filepath.Base(migration.Source)); err != nil {
|
||||
return fmt.Errorf("failed to print status: %w", err)
|
||||
|
|
Loading…
Reference in New Issue