Skip to content

fix: timestamp print ignores file/flush kwargs - #114

Open
andrewwhitecdw wants to merge 1 commit into
NVlabs:mainfrom
andrewwhitecdw:bugfix/demo-timestamp-print-ignores-file-flush
Open

fix: timestamp print ignores file/flush kwargs#114
andrewwhitecdw wants to merge 1 commit into
NVlabs:mainfrom
andrewwhitecdw:bugfix/demo-timestamp-print-ignores-file-flush

Conversation

@andrewwhitecdw

Copy link
Copy Markdown

Problem

fix: timestamp print ignores file/flush kwargs

Fix

Replace:

    def print_with_timestamp(*args, **kwargs):
        now = datetime.datetime.now()
        formatted_date_time = now.strftime(time_format)

        builtin_print(f'[{formatted_date_time}] ', end='')  # print with time stamp
        builtin_print(*args, **kwargs)

with:

    def print_with_timestamp(*args, **kwargs):
        now = datetime.datetime.now()
        formatted_date_time = now.strftime(time_format)

        common_kwargs = {k: v for k, v in kwargs.items() if k in ('file', 'flush')}
        builtin_print(f'[{formatted_date_time}] ', end='', **common_kwargs)  # print with time stamp
        builtin_print(*args, **kwargs)

Files changed

  • dust3r/demo.py

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant