~f4814n/frost

ac9cc1db801a0c734bd9e44811fd1bdd5ddfdb8a — Fabian Geiselhart 10 months ago 80ea2c0
Platform: Supply Logger
3 files changed, 17 insertions(+), 4 deletions(-)

M cmd/frost/main.go
M cmd/frost/platform_android.go
M cmd/frost/platform_linux.go
M cmd/frost/main.go => cmd/frost/main.go +1 -2
@@ 63,7 63,7 @@ func newApp() *App {
			app.Title("Frost"),
		),
		platform: platform,
		log:      logrus.WithField("component", "app"),
		log:      platform.Logger.WithField("component", "app"),
	}
}



@@ 299,7 299,6 @@ func (a *App) cacheFetchThumbnailEvent(e CacheFetchThumbnailEvent) {
}

func main() {
	logrus.SetLevel(logrus.DebugLevel)
	go func() {
		a := newApp()
		if err := a.run(); err != nil {

M cmd/frost/platform_android.go => cmd/frost/platform_android.go +13 -1
@@ 7,6 7,7 @@ import (
	"encoding/json"
	"git.sr.ht/~f4814n/matrix"
	"git.sr.ht/~f4814n/matrix/util/cache"
	"github.com/sirupsen/logrus"
	backend "git.sr.ht/~f4814n/matrix/backend/sqlite"
)



@@ 18,6 19,7 @@ var (
)

type Platform struct {
	Logger *logrus.Logger
	Cache cache.Cache
}



@@ 29,7 31,17 @@ func InitPlatform() Platform {
		panic(err.Error())
	}

	return Platform{Cache: cache}
	// Initialize Logfile
	logFile, err := os.OpenFile(baseDir + "/frost.log", os.O_CREATE|os.O_WRONLY|os.O_APPEND, 0666)
	if err != nil {
		panic(err.Error())
	}

	log := logrus.New()
	log.SetLevel(logrus.DebugLevel)
	log.Out = logFile

	return Platform{Cache: cache, Logger: log}
}

func (p Platform) LoadConfig() (cfg AppConfig, err error) {

M cmd/frost/platform_linux.go => cmd/frost/platform_linux.go +3 -1
@@ 4,6 4,7 @@ package main

import (
	"encoding/json"
	"github.com/sirupsen/logrus"
	"fmt"
	"git.sr.ht/~f4814n/matrix"
	backend "git.sr.ht/~f4814n/matrix/backend/sqlite"


@@ 18,6 19,7 @@ var (
)

type Platform struct {
	Logger *logrus.Logger
	Cache cache.Cache
}



@@ 34,7 36,7 @@ func InitPlatform() Platform {
		panic(err.Error())
	}

	return Platform{Cache: cache}
	return Platform{Cache: cache, Logger: logrus.New()}
}

func (p Platform) LoadConfig() (cfg AppConfig, err error) {