Skip to content

Commit

Permalink
Minor improvements in python logging
Browse files Browse the repository at this point in the history
  • Loading branch information
jakubno committed Sep 4, 2023
1 parent baf5c24 commit 35bd9bc
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .changeset/dirty-nails-sniff.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@e2b/python-sdk": patch
---

Minor improvements in logging
9 changes: 6 additions & 3 deletions packages/python-sdk/e2b/session/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
from e2b.session.session_connection import SessionConnection
from e2b.session.terminal import TerminalManager


logger = logging.getLogger(__name__)

Environment = Literal[
"Nodejs",
"Bash",
Expand Down Expand Up @@ -85,7 +88,7 @@ def __init__(
:param on_scan_ports: A callback to handle opened ports
"""

logging.info(f"Creating session {id if isinstance(id, str) else type(id)}")
logger.info(f"Creating session {id if isinstance(id, str) else type(id)}")
super().__init__(
id=id,
api_key=api_key,
Expand All @@ -108,11 +111,11 @@ async def open(self, timeout: Optional[float] = TIMEOUT) -> None:
:param timeout: Specify the duration, in seconds to give the method to finish its execution before it times out (default is 60 seconds). If set to None, the method will continue to wait until it completes, regardless of time
"""
logging.info(f"Opening session {self._id}")
logger.info(f"Opening session {self._id}")
async with async_timeout(timeout):
await super().open()
await self._code_snippet._subscribe()
logging.info(f"Session {self._id} opened")
logger.info(f"Session {self._id} opened")

def _close_services(self):
self._terminal._close()
Expand Down
2 changes: 1 addition & 1 deletion packages/python-sdk/e2b/session/session_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ async def close(self) -> None:

self._close()
logger.info(
f"Session {self._session.code_snippet_id} closed (id: {self._session.session_id})"
f"Session closed"
)

def _close(self):
Expand Down

0 comments on commit 35bd9bc

Please sign in to comment.