Skip to content

Add logging of print statements #83

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 13 commits into
base: dev
Choose a base branch
from
Open

Conversation

eyoung55
Copy link
Collaborator

@eyoung55 eyoung55 commented Apr 18, 2025

This PR adds a function to redirect all normal print statements to also be captured in a logfile. The file is situated at the top-level output directory, e.g., {params.general.output_dir}/logfile.log. Entries in the logfile are timestamped and marked INFO or ERROR.

Changes:

  • Call the start_print_and_log function immediately after parsing the user params
  • Added a function to redirect stdout and stderr to the normal terminal/command line display but also write a copy of the message to a log file

closes #56

@eyoung55
Copy link
Collaborator Author

Example logfile.log

2025-04-18 17:13:41 [INFO] Starting PVade Run
2025-04-18 17:13:41 [INFO] vol_tag_list =
2025-04-18 17:13:41 [INFO] [(2, 2), (2, 3)]
2025-04-18 17:13:41 [INFO] structure
2025-04-18 17:13:41 [INFO] 2
2025-04-18 17:13:41 [INFO] fluid
2025-04-18 17:13:41 [INFO] 3
2025-04-18 17:13:41 [INFO] Making structure = 9
2025-04-18 17:13:41 [INFO] Making fluid = 10
2025-04-18 17:13:41 [INFO] Starting mesh generation...
2025-04-18 17:13:41 [INFO] Finished.
2025-04-18 17:13:41 [INFO] Total meshing time = 0.0 s
2025-04-18 17:13:41 [INFO] Creating fluid submesh
...

@eyoung55 eyoung55 requested a review from arswalid May 1, 2025 19:59
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