Skip to content

Commit

Permalink
Added function to allow dynamic logging configuration using a provide…
Browse files Browse the repository at this point in the history
…d dictionary. (#82)
  • Loading branch information
RINO-GAELICO authored Oct 15, 2024
1 parent ac259e0 commit 4923203
Showing 1 changed file with 13 additions and 0 deletions.
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

0 comments on commit 4923203

Please sign in to comment.