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
3 changes: 3 additions & 0 deletions CHANGELOG.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
v1.0.12
- Properly decode argument to number or string
- Make default level from CLI = None
v1.0.11
- Set minimum requirement to python 3.8
v1.0.10
Expand Down
9 changes: 6 additions & 3 deletions logistro/_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,11 @@ def betterConfig(**kwargs: Any) -> None: # noqa: N802 camel-case like logging
implicit = kwargs.pop("implicit", False)
# its implicitly called and we're already setup
if not implicit or not logging.getLogger().handlers:
if "level" not in kwargs:
kwargs["level"] = cli_args.parsed.log.upper()
if "level" not in kwargs and cli_args.parsed.log:
if cli_args.parsed.log.isnumeric():
kwargs["level"] = int(cli_args.parsed.log)
else:
kwargs["level"] = cli_args.parsed.log.upper()
logging.basicConfig(**kwargs)
coerce_logger(logging.getLogger())
betterConfig.__code__ = (lambda **_kwargs: None).__code__
Expand All @@ -144,7 +147,7 @@ def betterConfig(**kwargs: Any) -> None: # noqa: N802 camel-case like logging
def getLogger(name: str | None = None) -> _LogistroLogger: # noqa: N802 camel-case like logging
"""Call `logging.getLogger()` but check `betterConfig()` first."""
betterConfig(implicit=True)
return cast(_LogistroLogger, logging.getLogger(name))
return cast("_LogistroLogger", logging.getLogger(name))


_LoggerFilter = Callable[[logging.LogRecord, Dict[str, Any]], bool]
Expand Down
5 changes: 3 additions & 2 deletions logistro/_args.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,10 @@

parser.add_argument(
"--logistro-level",
default="WARNING",
default=None,
type=str,
dest="log",
help="Set the logging level (default WARNING)",
help="Set the logging level (no default, fallback to system default)",
)

# Get the Format
Expand Down
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ ignore = [
"SIM105", # Too opionated (try-except-pass)
"PT003", # scope="function" implied but I like readability
"G004", # I like fstrings in my log

]

[tool.ruff.lint.per-file-ignores]
Expand Down
Loading