Skip to content

Commit

Permalink
chore: Add logging for step duration in Step class
Browse files Browse the repository at this point in the history
  • Loading branch information
yangbobo2021 committed May 18, 2024
1 parent cd7b56b commit 53dc010
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions lib/chatmark/step.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
from contextlib import AbstractContextManager
import time

from lib.ide_service import IDEService

class Step(AbstractContextManager):
"""
Expand All @@ -19,10 +21,16 @@ class Step(AbstractContextManager):

def __init__(self, title: str):
self.title = title
self.enter_time = time.time()

def __enter__(self):
print(f"\n```Step\n# {self.title}", flush=True)

def __exit__(self, exc_type, exc_val, exc_tb):
# close the step
end_time = time.time()
IDEService().ide_logging(
"debug",
f"Step {self.title} took {end_time - self.enter_time:.2f} seconds"
)
print("\n```", flush=True)

0 comments on commit 53dc010

Please sign in to comment.