Skip to content

Commit

Permalink
feat: add option to disable configuration logs
Browse files Browse the repository at this point in the history
  • Loading branch information
torives committed Mar 15, 2024
1 parent b0cff76 commit 4590499
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Added verification to ensure CARTESI_BLOCKCHAIN_ID matches the id returned from the Ethereum node
- Added support for CARTESI_AUTH_PRIVATE_KEY and CARTESI_AUTH_PRIVATE_KEY_FILE
- Added `CARTESI_EXPERIMENTAL_SERVER_MANAGER_BYPASS_LOG` env var to allow `server-manager` output to bypass all log configuration
- Added `CARTESI_EXPERIMENTAL_DISABLE_CONFIG_LOG` env var to disable log entries related to the node's configuration

## Changed

Expand Down
7 changes: 7 additions & 0 deletions docs/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,13 @@ Address of the InputBox contract.

* **Type:** `string`

## `CARTESI_EXPERIMENTAL_DISABLE_CONFIG_LOG`

Disables all log entries related to the node's configuration

* **Type:** `bool`
* **Default:** `"false"`

## `CARTESI_EXPERIMENTAL_SERVER_MANAGER_BYPASS_LOG`

When enabled, prints server-manager output to stdout and stderr directly.
Expand Down
4 changes: 4 additions & 0 deletions internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ package config

import (
"fmt"
"io"
"log"
"os"
"strconv"
Expand Down Expand Up @@ -104,6 +105,9 @@ var configLogger = log.New(os.Stdout, "CONFIG ", log.LstdFlags)

func init() {
cache.values = make(map[string]string)
if GetCartesiExperimentalDisableConfigLog() {
configLogger.SetOutput(io.Discard)
}
}

// Reads the value of an environment variable (loads from a cached value when possible).
Expand Down
9 changes: 8 additions & 1 deletion internal/config/generate/Config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -261,4 +261,11 @@ default = "false"
go-type = "bool"
description = """
When enabled, prints server-manager output to stdout and stderr directly.
All other log configurations are ignored."""
All other log configurations are ignored."""

[experimental.CARTESI_EXPERIMENTAL_DISABLE_CONFIG_LOG]
default = "false"
go-type = "bool"
redact = true
description = """
Disables all log entries related to the node's configuration"""
5 changes: 5 additions & 0 deletions internal/config/get.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 4590499

Please sign in to comment.