refactor: add zap logger

This commit is contained in:
Derrick Hammer 2023-05-17 13:34:44 -04:00
parent 0a90ff6439
commit 748cac542e
Signed by: pcfreak30
GPG Key ID: C997C339BE476FF2
2 changed files with 20 additions and 0 deletions

View File

@ -8,6 +8,7 @@ import (
_ "git.lumeweb.com/LumeWeb/portal/docs" _ "git.lumeweb.com/LumeWeb/portal/docs"
"git.lumeweb.com/LumeWeb/portal/renterd" "git.lumeweb.com/LumeWeb/portal/renterd"
"git.lumeweb.com/LumeWeb/portal/service/files" "git.lumeweb.com/LumeWeb/portal/service/files"
"git.lumeweb.com/LumeWeb/portal/shared"
"git.lumeweb.com/LumeWeb/portal/tus" "git.lumeweb.com/LumeWeb/portal/tus"
"git.lumeweb.com/LumeWeb/portal/validator" "git.lumeweb.com/LumeWeb/portal/validator"
"github.com/iris-contrib/swagger" "github.com/iris-contrib/swagger"
@ -48,6 +49,7 @@ func main() {
renterd.Ready() renterd.Ready()
shared.Init()
files.Init() files.Init()
// Create a new Iris app instance // Create a new Iris app instance

View File

@ -4,11 +4,15 @@ import (
"github.com/golang-queue/queue" "github.com/golang-queue/queue"
"github.com/tus/tusd/pkg/filestore" "github.com/tus/tusd/pkg/filestore"
tusd "github.com/tus/tusd/pkg/handler" tusd "github.com/tus/tusd/pkg/handler"
"go.uber.org/zap"
_ "go.uber.org/zap"
"log"
) )
var tusQueue *queue.Queue var tusQueue *queue.Queue
var tusStore *filestore.FileStore var tusStore *filestore.FileStore
var tusComposer *tusd.StoreComposer var tusComposer *tusd.StoreComposer
var logger *zap.Logger
func SetTusQueue(q *queue.Queue) { func SetTusQueue(q *queue.Queue) {
tusQueue = q tusQueue = q
@ -33,3 +37,17 @@ func SetTusComposer(c *tusd.StoreComposer) {
func GetTusComposer() *tusd.StoreComposer { func GetTusComposer() *tusd.StoreComposer {
return tusComposer return tusComposer
} }
func Init() {
newLogger, err := zap.NewProduction()
if err != nil {
log.Fatal(err)
}
logger = newLogger
}
func GetLogger() *zap.Logger {
return logger
}