-
-
Notifications
You must be signed in to change notification settings - Fork 102
Programming: Logging
Joshua Newton edited this page Nov 10, 2020
·
4 revisions
Should use sct.printv
, which is a modified version of Python's print to deal with color. Example:
import sct_utils as sct
sct.printv('Running segmentation, type='normal')
sct.printv('Finished! To view results, type: XYZ, type='info')
Here we should not use printing, but logging instead. A logger is defined at the beginning of each library's file and later called in the code. Example:
# Start of module
import logging
logger = logging.getLogger(__name__)
# Within code
logger.info("Running segmentation...")
logger.debug(f"Centerline fitting error is: {fitting_error}")
For each SCT script, the logging level is controlled using -v
. However, as of this edit, verbosity for printv/logging is inconsistent between scripts. This is an active issue being discussed in https://github.com/neuropoly/spinalcordtoolbox/issues/2676.
Editing the Wiki? If you're adding a new page or changing a title, be sure it fits the existing Wiki Structure.