Skip to content
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

Celery logging config #1904

Merged
merged 4 commits into from
Jun 14, 2024
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
6 changes: 4 additions & 2 deletions src/palace/manager/celery/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,13 @@ def import_celery_tasks() -> None:

@setup_logging.connect
def celery_logger_setup(loglevel: int, logfile: str | None, **kwargs: Any) -> None:
container_level = services.logging.config.level().levelno # type: ignore[attr-defined]
services = container_instance()
level = services.logging.config.level() # type: ignore[attr-defined]
container_level = level.levelno if level is not None else None
root_logger = logging.getLogger()

# If celery requested a lower log level, then we update the root logger to use the lower level.
if loglevel < container_level:
if container_level is None or loglevel < container_level:
root_logger.setLevel(loglevel)

# If celery requested a log file, then we update the root logger to also log to the file.
Expand Down
2 changes: 2 additions & 0 deletions tests/manager/celery/tasks/test_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
)
from palace.manager.scripts.initialization import InstanceInitializationScript
from palace.manager.search.external_search import Filter
from palace.manager.service.logging.configuration import LogLevel
from tests.fixtures.celery import CeleryFixture
from tests.fixtures.database import DatabaseTransactionFixture
from tests.fixtures.search import EndToEndSearchFixture
Expand Down Expand Up @@ -216,6 +217,7 @@ def test_index_work_failures(
caplog: pytest.LogCaptureFixture,
db: DatabaseTransactionFixture,
):
caplog.set_level(LogLevel.info)
# Make sure our backoff function doesn't delay the test.
mock_backoff.return_value = 0

Expand Down
1 change: 1 addition & 0 deletions tests/manager/celery/test_monitoring.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,7 @@ def test_on_shutter(
cloudwatch_camera: CloudwatchCameraFixture,
caplog: pytest.LogCaptureFixture,
):
caplog.set_level(LogLevel.warning)
cloudwatch = cloudwatch_camera.create_cloudwatch()
mock_publish = create_autospec(cloudwatch.publish)
cloudwatch.publish = mock_publish
Expand Down