Settings.log group

This commit is contained in:
Jörn-Michael Miehe 2023-08-31 23:29:27 +00:00
parent c5a3cac61e
commit 57da462dd7
3 changed files with 12 additions and 7 deletions

2
.vscode/launch.json vendored
View file

@ -11,7 +11,7 @@
"module": "kiwi_simple_metrics.main",
"env": {
"METRIC__INTERVAL": "5",
"METRIC__QUIET": "False",
"METRIC__LOG__ENABLED": "True",
"METRIC__DISK__PATHS": "[\"/var\", \"/\", \"/dev\"]",
},
"justMyCode": true

View file

@ -16,7 +16,7 @@ async def run_metrics() -> None:
metrics.disk(),
)
if not SETTINGS.quiet:
if SETTINGS.log.enabled:
print(report)
await interval

View file

@ -82,6 +82,14 @@ class DiskMS(MetricSettings):
paths: list[DirectoryPath] = Field(default_factory=list)
class LogSettings(BaseModel):
# if True, prints reports to stdout
enabled: bool = False
# how to format reports to stdout
format: str = "[{state}] {result}"
class Settings(BaseSettings):
model_config = SettingsConfigDict(
env_prefix="METRIC__",
@ -91,11 +99,8 @@ class Settings(BaseSettings):
# time between gathering reports
interval: float = 600
# if False, prints reports to stdout
quiet: bool = True
# how to format reports to stdout
report_stdout: str = "[{state}] {result}"
# reporting to stdout
log: LogSettings = LogSettings()
# separates metrics and values in reports
separator: str = ", "