-
Notifications
You must be signed in to change notification settings - Fork 4
Logging improvements #374
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Logging improvements #374
Changes from all commits
62aac02
cae513d
577ae0f
5852f0b
65f5dd0
0c435b5
ae09555
b1f8543
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -258,7 +258,7 @@ | |
| async def serialisation_error_handler( | ||
| request: Request, exc: PydanticSerializationError | ||
| ) -> JSONResponse: | ||
| LOGGER.error( | ||
| f"Couldn't serialise response to {request.url} because of error: \n" | ||
| f"{exc}" | ||
| ) | ||
|
|
@@ -307,6 +307,14 @@ | |
| """ | ||
| return self._config.api_prefix | ||
|
|
||
| @property | ||
| def global_lock_log_level(self) -> int: | ||
| """The level at which to log when the global lock is busy.""" | ||
| # Note that the config entry below is validated by the config | ||
| # model, to be one of DEBUG, INFO, WARNING or ERROR. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Currently no. It may make sense to add this. I believe it's currently self consistent so I'm tempted to suggest we merge this without, and can make another pr to add USER as an option. |
||
| levelname = self._config.global_lock_log_level | ||
| return getattr(logging, levelname) | ||
|
|
||
| ThingInstance = TypeVar("ThingInstance", bound=Thing) | ||
|
|
||
| def things_by_class(self, cls: type[ThingInstance]) -> Sequence[ThingInstance]: | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,7 +8,7 @@ | |
| """ | ||
|
|
||
| from collections.abc import Iterable, Mapping, Sequence | ||
| from typing import Annotated, Any, TypeAlias | ||
| from typing import Annotated, Any, Literal, TypeAlias | ||
|
|
||
| from pydantic import ( | ||
| AfterValidator, | ||
|
|
@@ -236,6 +236,14 @@ def thing_configs(self) -> Mapping[ThingName, ThingConfig]: | |
| ), | ||
| ) | ||
|
|
||
| global_lock_log_level: Literal["DEBUG", "INFO", "WARNING", "ERROR"] = Field( | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Test would also need to be updated, if this is changed |
||
| default="INFO", | ||
| description=( | ||
| "The log level to use when an action can't start due to the global lock " | ||
| "being busy." | ||
| ), | ||
| ) | ||
|
|
||
| application_config: dict[str, Any] | None = Field( | ||
| default=None, | ||
| description=( | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It says 'if supplied', but thing_name isn't Optional in the type hint which makes this a bit confusing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for spotting, I'll adjust the type hint. It's correct in the code, just wrong on this page.