Rename log.LevelCritical to log.LevelFatal

This commit is contained in:
Deluan 2022-12-21 14:53:36 -05:00
parent 28389fb05e
commit 5943e8f953
26 changed files with 40 additions and 46 deletions

View File

@ -11,7 +11,7 @@ import (
func TestAgents(t *testing.T) {
tests.Init(t, false)
log.SetLevel(log.LevelCritical)
log.SetLevel(log.LevelFatal)
RegisterFailHandler(Fail)
RunSpecs(t, "Agents Test Suite")
}

View File

@ -11,7 +11,7 @@ import (
func TestLastFM(t *testing.T) {
tests.Init(t, false)
log.SetLevel(log.LevelCritical)
log.SetLevel(log.LevelFatal)
RegisterFailHandler(Fail)
RunSpecs(t, "LastFM Test Suite")
}

View File

@ -11,7 +11,7 @@ import (
func TestListenBrainz(t *testing.T) {
tests.Init(t, false)
log.SetLevel(log.LevelCritical)
log.SetLevel(log.LevelFatal)
RegisterFailHandler(Fail)
RunSpecs(t, "ListenBrainz Test Suite")
}

View File

@ -11,7 +11,7 @@ import (
func TestSpotify(t *testing.T) {
tests.Init(t, false)
log.SetLevel(log.LevelCritical)
log.SetLevel(log.LevelFatal)
RegisterFailHandler(Fail)
RunSpecs(t, "Spotify Test Suite")
}

View File

@ -15,7 +15,7 @@ import (
)
func TestAuth(t *testing.T) {
log.SetLevel(log.LevelCritical)
log.SetLevel(log.LevelFatal)
RegisterFailHandler(Fail)
RunSpecs(t, "Auth Test Suite")
}

View File

@ -11,7 +11,7 @@ import (
func TestCore(t *testing.T) {
tests.Init(t, false)
log.SetLevel(log.LevelCritical)
log.SetLevel(log.LevelFatal)
RegisterFailHandler(Fail)
RunSpecs(t, "Core Suite")
}

View File

@ -11,7 +11,7 @@ import (
func TestAgents(t *testing.T) {
tests.Init(t, false)
log.SetLevel(log.LevelCritical)
log.SetLevel(log.LevelFatal)
RegisterFailHandler(Fail)
RunSpecs(t, "Scrobbler Test Suite")
}

View File

@ -11,7 +11,7 @@ import (
func TestTranscoder(t *testing.T) {
tests.Init(t, false)
log.SetLevel(log.LevelCritical)
log.SetLevel(log.LevelFatal)
RegisterFailHandler(Fail)
RunSpecs(t, "Transcoder Suite")
}

View File

@ -3,7 +3,6 @@ package db
import (
"database/sql"
"fmt"
"os"
_ "github.com/mattn/go-sqlite3"
"github.com/navidrome/navidrome/conf"
@ -59,21 +58,18 @@ func EnsureLatestVersion() {
err = goose.SetDialect(Driver)
if err != nil {
log.Error("Invalid DB driver", "driver", Driver, err)
os.Exit(1)
log.Fatal("Invalid DB driver", "driver", Driver, err)
}
err = goose.Run("up", db, "./")
if err != nil {
log.Error("Failed to apply new migrations", err)
os.Exit(1)
log.Fatal("Failed to apply new migrations", err)
}
}
func isSchemaEmpty(db *sql.DB) bool { // nolint:interfacer
rows, err := db.Query("SELECT name FROM sqlite_master WHERE type='table' AND name='goose_db_version';") // nolint:rowserrcheck
if err != nil {
log.Error("Database could not be opened!", err)
os.Exit(1)
log.Fatal("Database could not be opened!", err)
}
defer rows.Close()
return !rows.Next()
@ -84,13 +80,11 @@ type logAdapter struct {
}
func (l *logAdapter) Fatal(v ...interface{}) {
log.Error(fmt.Sprint(v...))
os.Exit(-1)
log.Fatal(fmt.Sprint(v...))
}
func (l *logAdapter) Fatalf(format string, v ...interface{}) {
log.Error(fmt.Sprintf(format, v...))
os.Exit(-1)
log.Fatal(fmt.Sprintf(format, v...))
}
func (l *logAdapter) Print(v ...interface{}) {

View File

@ -12,7 +12,7 @@ import (
func TestDB(t *testing.T) {
tests.Init(t, false)
log.SetLevel(log.LevelCritical)
log.SetLevel(log.LevelFatal)
RegisterFailHandler(Fail)
RunSpecs(t, "DB Suite")
}

View File

@ -41,12 +41,12 @@ var redacted = &Hook{
}
const (
LevelCritical = Level(logrus.FatalLevel) // TODO Rename to LevelFatal
LevelError = Level(logrus.ErrorLevel)
LevelWarn = Level(logrus.WarnLevel)
LevelInfo = Level(logrus.InfoLevel)
LevelDebug = Level(logrus.DebugLevel)
LevelTrace = Level(logrus.TraceLevel)
LevelFatal = Level(logrus.FatalLevel)
LevelError = Level(logrus.ErrorLevel)
LevelWarn = Level(logrus.WarnLevel)
LevelInfo = Level(logrus.InfoLevel)
LevelDebug = Level(logrus.DebugLevel)
LevelTrace = Level(logrus.TraceLevel)
)
type contextKey string
@ -82,8 +82,8 @@ func levelFromString(l string) Level {
envLevel := strings.ToLower(l)
var level Level
switch envLevel {
case "critical":
level = LevelCritical
case "fatal":
level = LevelFatal
case "error":
level = LevelError
case "warn":
@ -147,7 +147,7 @@ func CurrentLevel() Level {
}
func Fatal(args ...interface{}) {
log(LevelCritical, args...)
log(LevelFatal, args...)
os.Exit(1)
}

View File

@ -167,9 +167,9 @@ var _ = Describe("Logger", func() {
})
Describe("SetLevelString", func() {
It("converts Critical level", func() {
SetLevelString("Critical")
Expect(CurrentLevel()).To(Equal(LevelCritical))
It("converts Fatal level", func() {
SetLevelString("Fatal")
Expect(CurrentLevel()).To(Equal(LevelFatal))
})
It("converts Error level", func() {
SetLevelString("ERROR")

View File

@ -10,7 +10,7 @@ import (
)
func TestCriteria(t *testing.T) {
log.SetLevel(log.LevelCritical)
log.SetLevel(log.LevelFatal)
gomega.RegisterFailHandler(Fail)
RunSpecs(t, "Criteria Suite")
}

View File

@ -12,7 +12,7 @@ import (
func TestModel(t *testing.T) {
tests.Init(t, true)
log.SetLevel(log.LevelCritical)
log.SetLevel(log.LevelFatal)
RegisterFailHandler(Fail)
RunSpecs(t, "Model Suite")
}

View File

@ -16,7 +16,7 @@ var _ = Describe("SQLStore", func() {
BeforeEach(func() {
ds = New(db.Db())
ctx = context.Background()
log.SetLevel(log.LevelCritical)
log.SetLevel(log.LevelFatal)
})
AfterEach(func() {
log.SetLevel(log.LevelError)

View File

@ -11,7 +11,7 @@ import (
func TestFFMpeg(t *testing.T) {
tests.Init(t, true)
log.SetLevel(log.LevelCritical)
log.SetLevel(log.LevelFatal)
RegisterFailHandler(Fail)
RunSpecs(t, "FFMpeg Suite")
}

View File

@ -11,7 +11,7 @@ import (
func TestMetadata(t *testing.T) {
tests.Init(t, true)
log.SetLevel(log.LevelCritical)
log.SetLevel(log.LevelFatal)
RegisterFailHandler(Fail)
RunSpecs(t, "Metadata Suite")
}

View File

@ -11,7 +11,7 @@ import (
func TestTagLib(t *testing.T) {
tests.Init(t, true)
log.SetLevel(log.LevelCritical)
log.SetLevel(log.LevelFatal)
RegisterFailHandler(Fail)
RunSpecs(t, "TagLib Suite")
}

View File

@ -17,7 +17,7 @@ func TestScanner(t *testing.T) {
conf.Server.DbPath = "file::memory:?cache=shared"
_ = orm.RegisterDataBase("default", db.Driver, conf.Server.DbPath)
db.EnsureLatestVersion()
log.SetLevel(log.LevelCritical)
log.SetLevel(log.LevelFatal)
RegisterFailHandler(Fail)
RunSpecs(t, "Scanner Suite")
}

View File

@ -11,7 +11,7 @@ import (
func TestEvents(t *testing.T) {
tests.Init(t, false)
log.SetLevel(log.LevelCritical)
log.SetLevel(log.LevelFatal)
RegisterFailHandler(Fail)
RunSpecs(t, "Events Suite")
}

View File

@ -11,7 +11,7 @@ import (
func TestNativeApi(t *testing.T) {
tests.Init(t, false)
log.SetLevel(log.LevelCritical)
log.SetLevel(log.LevelFatal)
RegisterFailHandler(Fail)
RunSpecs(t, "Native RESTful API Suite")
}

View File

@ -11,7 +11,7 @@ import (
func TestServer(t *testing.T) {
tests.Init(t, false)
log.SetLevel(log.LevelCritical)
log.SetLevel(log.LevelFatal)
RegisterFailHandler(Fail)
RunSpecs(t, "Server Suite")
}

View File

@ -9,7 +9,7 @@ import (
)
func TestSubsonicApi(t *testing.T) {
log.SetLevel(log.LevelCritical)
log.SetLevel(log.LevelFatal)
RegisterFailHandler(Fail)
RunSpecs(t, "Subsonic API Suite")
}

View File

@ -11,7 +11,7 @@ import (
func TestCache(t *testing.T) {
tests.Init(t, false)
log.SetLevel(log.LevelCritical)
log.SetLevel(log.LevelFatal)
RegisterFailHandler(Fail)
RunSpecs(t, "Cache Suite")
}

View File

@ -12,7 +12,7 @@ import (
func TestGravatar(t *testing.T) {
tests.Init(t, false)
log.SetLevel(log.LevelCritical)
log.SetLevel(log.LevelFatal)
RegisterFailHandler(Fail)
RunSpecs(t, "Gravatar Test Suite")
}

View File

@ -12,7 +12,7 @@ import (
func TestPool(t *testing.T) {
tests.Init(t, false)
log.SetLevel(log.LevelCritical)
log.SetLevel(log.LevelFatal)
RegisterFailHandler(Fail)
RunSpecs(t, "Pool Suite")
}