Skip to content

Commit

Permalink
adds log level conf to proxyd (ethereum-optimism#3704)
Browse files Browse the repository at this point in the history
  • Loading branch information
Zach Howard authored Oct 14, 2022
1 parent ed38dc6 commit f4faa44
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/wet-cameras-cover.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@eth-optimism/proxyd': minor
---

adds server.log_level config
15 changes: 15 additions & 0 deletions proxyd/cmd/proxyd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,21 @@ func main() {
log.Crit("error reading config file", "err", err)
}

// update log level from config
logLevel, err := log.LvlFromString(config.Server.LogLevel)
if err != nil {
logLevel = log.LvlInfo
if config.Server.LogLevel != "" {
log.Warn("invalid server.log_level set: " + config.Server.LogLevel)
}
}
log.Root().SetHandler(
log.LvlFilterHandler(
logLevel,
log.StreamHandler(os.Stdout, log.JSONFormat()),
),
)

shutdown, err := proxyd.Start(config)
if err != nil {
log.Crit("error starting proxyd", "err", err)
Expand Down
1 change: 1 addition & 0 deletions proxyd/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ type ServerConfig struct {
WSPort int `toml:"ws_port"`
MaxBodySizeBytes int64 `toml:"max_body_size_bytes"`
MaxConcurrentRPCs int64 `toml:"max_concurrent_rpcs"`
LogLevel string `toml:"log_level"`

// TimeoutSeconds specifies the maximum time spent serving an HTTP request. Note that isn't used for websocket connections
TimeoutSeconds int `toml:"timeout_seconds"`
Expand Down
2 changes: 2 additions & 0 deletions proxyd/example.config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ ws_port = 8085
# Maximum client body size, in bytes, that the server will accept.
max_body_size_bytes = 10485760
max_concurrent_rpcs = 1000
# Server log level
log_level = "info"

[redis]
# URL to a Redis instance.
Expand Down

0 comments on commit f4faa44

Please sign in to comment.