Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions sotrplib/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,18 @@
Command-line interface for sotrplib.
"""

import logging
from argparse import ArgumentParser
from pathlib import Path

import structlog

from sotrplib.config.config import Settings

structlog.configure(
wrapper_class=structlog.make_filtering_bound_logger(logging.INFO),
)


def parse_args() -> ArgumentParser:
ap = ArgumentParser(
Expand Down
6 changes: 6 additions & 0 deletions sotrplib/config/config.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import logging
from pathlib import Path
from typing import Any, Literal

Expand Down Expand Up @@ -102,6 +103,8 @@ class Settings(BaseSettings):
profile: bool = False
"Enable pyinstrument profiling"

log_level: int | str = logging.INFO

# Read environment and command line settings to override default
model_config = SettingsConfigDict(env_prefix="sotrp_", extra="ignore")

Expand All @@ -112,6 +115,9 @@ def from_file(cls, config_path: Path | str) -> "Settings":
return cls.model_validate_json(handle.read())

def to_dependencies(self) -> dict[str, Any]:
structlog.configure(
wrapper_class=structlog.make_filtering_bound_logger(self.log_level),
)
log = structlog.get_logger()

contents = {
Expand Down
Loading