Skip to content

Commit

Permalink
add guard for math.log in size calculation (#637)
Browse files Browse the repository at this point in the history
  • Loading branch information
mmckerns committed Dec 22, 2023
1 parent 6343f44 commit 8d209d4
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions dill/logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,8 +200,8 @@ def format(self, record):
if not self.is_utf8:
prefix = prefix.translate(ASCII_MAP) + "-"
fields['prefix'] = prefix + " "
if hasattr(record, 'size'):
# Show object size in human-redable form.
if hasattr(record, 'size') and record.size is not None and record.size >= 1:
# Show object size in human-readable form.
power = int(math.log(record.size, 2)) // 10
size = record.size >> power*10
fields['suffix'] = " [%d %sB]" % (size, "KMGTP"[power] + "i" if power else "")
Expand Down

0 comments on commit 8d209d4

Please sign in to comment.