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

Added function to allow dynamic logging configuration using a provided dictionary. #82

Merged
merged 3 commits into from
Oct 15, 2024
Merged
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
13 changes: 13 additions & 0 deletions healthchain/decorators.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import logging
import logging.config
import threading
import asyncio
import json
Expand Down Expand Up @@ -215,6 +216,7 @@ def start_sandbox(
service_id: str = "1",
save_data: bool = True,
save_dir: str = "./output/",
logging_config: Optional[Dict] = None,
) -> None:
"""
Starts the sandbox: initialises service and sends a request through the client.
Expand All @@ -229,6 +231,17 @@ def start_sandbox(

self.sandbox_id = uuid.uuid4()

if logging_config:
logging.config.dictConfig(logging_config)
else:
# Set up default logging configuration
logging.basicConfig(
level=logging.INFO,
format="%(asctime)s - %(name)s - %(levelname)s - %(message)s",
)

log = logging.getLogger(__name__)

# Start service on thread
log.info(
f"Starting sandbox {self.sandbox_id} with {self.__class__.__name__} of type {self.type.value}..."
Expand Down
Loading