You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Feb 6, 2026. It is now read-only.
We want to set up a system for logging information about the progress of reconstruction algorithms such as convergence criteria and which number of iterations have been completed. This system should probably use the standard logger of python and print statements for storing information optionally.
Instead of changing the API of tike to accommodate development, we can use the following tools to capture data in text files and display messages to stout.
Example
Here's an example that demonstrates these concepts.
dev_logging.py:
#!/usr/bin/env python# -*- coding: utf-8 -*-"""Define an example of the logging system to be used in tike."""importnumpyasnpimportlogging# First set the logging level to logging.INFO.logging.basicConfig(level=logging.INFO)
# Then we need to grab a reference to the existing logger or make a new one.logger=logging.getLogger(__name__)
if__name__=='__main__':
# Go to https://pyformat.info/ for a summary of how to use format()print("{} is a random number.\nThis string will go to the standard output ""stream".format(np.random.randint(0, 100)))
logger.info("This is an info level statement.\nLogging statements go to ""standard error.")
logger.debug("This is a debugging level statement.\nIt appears when the ""logging level is det to DEBUG or higher.")
if__debug__:
print("This statement appears if Python was unoptimized.\n""i.e. if it was started without the -O option.")
logger.info("Good bye!")
Run the script in a bash terminal:
$ python -O dev_logging.py > some_data.txt
INFO:__main__:This is an info level statement.
INFO:__main__:Good bye!
some_data.txt:
46 is a random number.
This string will go to the standard outputstream
We want to set up a system for logging information about the progress of reconstruction algorithms such as convergence criteria and which number of iterations have been completed. This system should probably use the standard logger of python and print statements for storing information optionally.
Instead of changing the API of
tiketo accommodate development, we can use the following tools to capture data in text files and display messages tostout.Example
Here's an example that demonstrates these concepts.
dev_logging.py:
Run the script in a bash terminal:
some_data.txt: