Skip to content

Commit

Permalink
update to entries docs section, about log retrieval.
Browse files Browse the repository at this point in the history
  • Loading branch information
djl11 committed Feb 22, 2025
1 parent f1f6426 commit 9d93db2
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions logging/entries.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -103,15 +103,20 @@ when it's known that they are constant for all inner computation and logging.
By default, `unify.Entry("...")` also changes the behaviour of `get_logs`, returning only the logs which include the entry.

```python
for grade, students in {
"A": ["Alice", "Bob"],
"B": ["Charlie"],
"C": ["Eve", "Frank"]
}:
with unify.Entry(grade=grade):
for student in students:
unify.log(name=student)
assert len(unify.get_logs()) == len(students)
for subject, studate_data in all_student_data.items():
with unify.Entry(subject=subject):
for grade, students in studate_data.items():
with unify.Entry(grade=grade):
for first_name, last_name, dob in students:
unify.log(
first_name=first_name,
last_name=last_name,
data_of_birth=dob
)
assert len(unify.get_logs()) == len(students)
assert len(unify.get_logs()) == sum(
len(students) for students in studate_data.values()
)
```

This behaviour can be change by setting `unify.Entry("...", mode="read")` which will only impact log **getting**,
Expand Down

0 comments on commit 9d93db2

Please sign in to comment.