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 13, 2024
1 parent 742fd3e commit 8d6dfc0
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 @@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added

- 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

## [1.3.0] 2024-02-09

Expand Down
7 changes: 7 additions & 0 deletions docs/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,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 @@ -93,6 +94,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 @@ -243,4 +243,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 8d6dfc0

Please sign in to comment.