From 08556e6cbd7c83e974959132fb2403f69d78cc8b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=BDiga=20Kokelj?= Date: Tue, 6 Aug 2024 13:32:40 +0200 Subject: [PATCH 1/2] remove file logger from the gateway --- tools/walletextension/common/common.go | 14 -------------- tools/walletextension/rpcapi/utils.go | 2 +- tools/walletextension/rpcapi/wallet_extension.go | 3 --- 3 files changed, 1 insertion(+), 18 deletions(-) diff --git a/tools/walletextension/common/common.go b/tools/walletextension/common/common.go index a9a099b362..98212a9f60 100644 --- a/tools/walletextension/common/common.go +++ b/tools/walletextension/common/common.go @@ -3,10 +3,6 @@ package common import ( "encoding/json" "fmt" - "os" - - gethforklog "github.com/ten-protocol/go-ten/lib/gethfork/log" - gethrpc "github.com/ten-protocol/go-ten/lib/gethfork/rpc" "github.com/ethereum/go-ethereum/crypto" @@ -79,13 +75,3 @@ func (r *RPCRequest) Clone() *RPCRequest { Params: r.Params, } } - -// NewFileLogger is a logger factory function -func NewFileLogger() gethlog.Logger { - // Open or create your log file - file, err := os.OpenFile("gateway_logs.log", os.O_CREATE|os.O_APPEND|os.O_WRONLY, 0o644) - if err != nil { - panic(err) - } - return gethlog.NewLogger(gethlog.NewGlogHandler(gethforklog.NewTerminalHandler(file, false))) -} diff --git a/tools/walletextension/rpcapi/utils.go b/tools/walletextension/rpcapi/utils.go index a90eacb810..732fd45d2e 100644 --- a/tools/walletextension/rpcapi/utils.go +++ b/tools/walletextension/rpcapi/utils.go @@ -265,7 +265,7 @@ func withCache[R any](cache cache.Cache, cfg *CacheCfg, cacheKey []byte, onCache func audit(services *Services, msg string, params ...any) { if services.Config.VerboseFlag { - services.FileLogger.Info(fmt.Sprintf(msg, params...)) + services.logger.Info(fmt.Sprintf(msg, params...)) } } diff --git a/tools/walletextension/rpcapi/wallet_extension.go b/tools/walletextension/rpcapi/wallet_extension.go index fae47871f7..ddd9e1cf54 100644 --- a/tools/walletextension/rpcapi/wallet_extension.go +++ b/tools/walletextension/rpcapi/wallet_extension.go @@ -41,7 +41,6 @@ type Services struct { HostAddrWS string // The WS address on which the Ten host can be reached Storage storage.Storage logger gethlog.Logger - FileLogger gethlog.Logger stopControl *stopcontrol.StopControl version string Cache cache.Cache @@ -58,7 +57,6 @@ type NewHeadNotifier interface { } func NewServices(hostAddrHTTP string, hostAddrWS string, storage storage.Storage, stopControl *stopcontrol.StopControl, version string, logger gethlog.Logger, config *common.Config) *Services { - newFileLogger := common.NewFileLogger() newGatewayCache, err := cache.NewCache(logger) if err != nil { logger.Error(fmt.Errorf("could not create cache. Cause: %w", err).Error()) @@ -101,7 +99,6 @@ func NewServices(hostAddrHTTP string, hostAddrWS string, storage storage.Storage HostAddrWS: hostAddrWS, Storage: storage, logger: logger, - FileLogger: newFileLogger, stopControl: stopControl, version: version, Cache: newGatewayCache, From 432535ac390e16b1adf71cdc97c7b44791d5ac64 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=BDiga=20Kokelj?= Date: Wed, 7 Aug 2024 12:16:23 +0200 Subject: [PATCH 2/2] lint --- tools/walletextension/common/common.go | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/walletextension/common/common.go b/tools/walletextension/common/common.go index 98212a9f60..94ac8be729 100644 --- a/tools/walletextension/common/common.go +++ b/tools/walletextension/common/common.go @@ -3,6 +3,7 @@ package common import ( "encoding/json" "fmt" + gethrpc "github.com/ten-protocol/go-ten/lib/gethfork/rpc" "github.com/ethereum/go-ethereum/crypto"