Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove file logger from the gateway #2010

Merged
merged 2 commits into from
Aug 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 0 additions & 13 deletions tools/walletextension/common/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +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"

Expand Down Expand Up @@ -79,13 +76,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)))
}
2 changes: 1 addition & 1 deletion tools/walletextension/rpcapi/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -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...))
}
}

Expand Down
3 changes: 0 additions & 3 deletions tools/walletextension/rpcapi/wallet_extension.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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())
Expand Down Expand Up @@ -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,
Expand Down
Loading