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

Add log level option #62

Merged
merged 2 commits into from
Apr 20, 2023
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

IMPROVEMENTS:

- catalog: Add logging field in catalog [[GH-62](https://github.com/umbracle/eth2-validator/issues/62)]
- core: Add an alias for the deployment [[GH-23](https://github.com/umbracle/eth2-validator/issues/23)]

# 0.1.1 (18 April, 2023)
Expand Down
14 changes: 14 additions & 0 deletions internal/catalog/catalog.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,13 +119,27 @@ func (b *backend) generateStaticConfig() error {
b.fields[name] = res.ToType()
}

// append the default configuration fields
for name, res := range defaultConfiguration {
b.fields[name] = res
}

chainsValue := b.globals["chains"]
if err := mapstructure.Decode(toGoValue(chainsValue), &b.chains); err != nil {
return err
}
return nil
}

var defaultConfiguration = map[string]*framework.Field{
"log_level": {
Type: framework.TypeString,
Default: "info",
Description: "Log level for the logs emitted by the client",
AllowedValues: []interface{}{"all", "debug", "info", "warn", "error", "silent"},
},
}

func (b *backend) Config() map[string]*framework.Field {
return b.fields
}
Expand Down
6 changes: 6 additions & 0 deletions internal/catalog/templates/geth.star
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,12 @@ config = {
}
}

verbosity_levels = {"debug": "4", "info": "3", "warn": "2", "error": "1", "silent": "0"}


def generate(obj):
verbosity = verbosity_levels[obj["log_level"]]

t = {
"image": "ethereum/client-go",
"tag": "v1.11.5",
Expand All @@ -39,6 +43,8 @@ def generate(obj):
"/var/lib/jwtsecret/jwt.hex",
"--metrics.addr",
"0.0.0.0",
"--verbosity",
verbosity,
],
"data": {
"/var/lib/jwtsecret/jwt.hex": "04592280e1778419b7aa954d43871cb2cfb2ebda754fb735e8adeb293a88f9bf"
Expand Down
4 changes: 4 additions & 0 deletions internal/cmd/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ type DeployCommand struct {
metrics bool

alias string

logLevel string
}

// Help implements the cli.Command interface
Expand All @@ -48,6 +50,7 @@ func (c *DeployCommand) Run(args []string) int {
flags.StringVar(&c.params, "params", "", "")
flags.BoolVar(&c.metrics, "metrics", true, "")
flags.StringVar(&c.alias, "alias", "", "")
flags.StringVar(&c.logLevel, "log-level", "info", "")

if err := flags.Parse(args); err != nil {
c.UI.Error(err.Error())
Expand Down Expand Up @@ -96,6 +99,7 @@ func (c *DeployCommand) Run(args []string) int {
Chain: c.chain,
Metrics: c.metrics,
Alias: c.alias,
LogLevel: c.logLevel,
}
resp, err := clt.Apply(context.Background(), req)
if err != nil {
Expand Down
5 changes: 5 additions & 0 deletions internal/server/catalog.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ func (l *localCatalog) Build(prev []byte, req *proto.ApplyRequest) ([]byte, map[
return nil, nil, err
}

// add to input the typed parameters from the request
if req.LogLevel != "" {
inputMap["log_level"] = req.LogLevel
}

// validate the input and the state
state, data, err := processInput(cc.Config(), prevMap, inputMap)
if err != nil {
Expand Down
302 changes: 156 additions & 146 deletions internal/server/proto/vesta.pb.go

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions internal/server/proto/vesta.proto
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ message ApplyRequest {
string chain = 5;

string alias = 6;

string logLevel = 7;
}

message ApplyResponse {
Expand Down
2 changes: 2 additions & 0 deletions website/docs/cli/deploy.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ $ vesta deploy [params] [options]
- `chain`: (string): The chain you want to deploy. The plugin will filter if the chain name is correct.
- `alloc`: (string): The allocation if we are performing an update.
- `metrics`: (bool: true): Whether the node tracks metrics or not.
- `alias`: (string): The alias of the node. If set, you can use this name instead of the deployment id to refer to this node.
- `log-level`: (string): Logging level for the output log of the nodes. Available options: (`all`, `debug`, `info`, `warn`, `error`, `silent`). It defaults to `info`.

Each plugin also defines custom parameters that can be queried with the `catalog inspect` command. Those specific fields are passed as values to the cli but without a flag, for example `param=val` instead of `--param=val`.

Expand Down