mirror of
https://github.com/yavook/kiwi-simple-metrics.git
synced 2024-11-24 16:33:01 +00:00
Settings.log group
This commit is contained in:
parent
c5a3cac61e
commit
57da462dd7
3 changed files with 12 additions and 7 deletions
2
.vscode/launch.json
vendored
2
.vscode/launch.json
vendored
|
@ -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
|
||||
|
|
|
@ -16,7 +16,7 @@ async def run_metrics() -> None:
|
|||
metrics.disk(),
|
||||
)
|
||||
|
||||
if not SETTINGS.quiet:
|
||||
if SETTINGS.log.enabled:
|
||||
print(report)
|
||||
|
||||
await interval
|
||||
|
|
|
@ -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 = ", "
|
||||
|
|
Loading…
Reference in a new issue