diff --git a/.vscode/launch.json b/.vscode/launch.json index cd3eae0..b77d253 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -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 diff --git a/kiwi_simple_metrics/main.py b/kiwi_simple_metrics/main.py index a0fe787..06c0b59 100644 --- a/kiwi_simple_metrics/main.py +++ b/kiwi_simple_metrics/main.py @@ -16,7 +16,7 @@ async def run_metrics() -> None: metrics.disk(), ) - if not SETTINGS.quiet: + if SETTINGS.log.enabled: print(report) await interval diff --git a/kiwi_simple_metrics/settings.py b/kiwi_simple_metrics/settings.py index 49c2127..bb3fc1f 100644 --- a/kiwi_simple_metrics/settings.py +++ b/kiwi_simple_metrics/settings.py @@ -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 = ", "