Skip to content

Commit 7603e5d

Browse files
committed
add pretty print history method, for debugging help
1 parent 634f708 commit 7603e5d

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

azure/durable_functions/models/DurableOrchestrationContext.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
import json
22
import datetime
3+
import inspect
34
from typing import List, Any, Dict, Optional
45
from uuid import UUID, uuid5, NAMESPACE_URL
6+
from datetime import timezone
57

68
from .RetryOptions import RetryOptions
79
from .TaskSet import TaskSet
@@ -459,3 +461,14 @@ def new_guid(self) -> UUID:
459461
self._new_uuid_counter += 1
460462
guid = uuid5(NAMESPACE_URL, guid_name)
461463
return guid
464+
465+
def _pretty_print_history(self) -> str:
466+
def history_to_string(event):
467+
json_dict = {}
468+
for key, val in inspect.getmembers(event):
469+
if not key.startswith('_') and not inspect.ismethod(val):
470+
if isinstance(val, datetime.date):
471+
val = val.replace(tzinfo=timezone.utc).timetuple()
472+
json_dict[key] = val
473+
return json.dumps(json_dict)
474+
return list(map(history_to_string, self._histories))

0 commit comments

Comments
 (0)