pypeit.pypmsgs module
Module for terminal and file logging.
Todo
Why not use pythons native logging package?
- class pypeit.pypmsgs.Messages(log=None, verbosity=None, colors=True)[source]
Bases:
object
Create coloured text for messages printed to screen.
For further details on colours see the following example: http://ascii-table.com/ansi-escape-sequences.php
- Parameters:
log (str or file-like object,optional) – Name of saved log file (no log will be saved if log==””). If None, no log is saved.
verbosity (int) –
- Level of verbosity. Options are
0 = No output
1 = Minimal output
2 = All output (default)
colors (bool) – If true, the screen output will have colors, otherwise normal screen output will be displayed
- pypeitpar(msglist)[source]
Print a message with the pypeit par formatting.
- Parameters:
msglist (list) –
A list containing the pypeit parameter strings. The last element of the list must be the argument and the variable. For example, to print:
[sensfunc] [[UVIS]] polycorrect = False
you should set
msglist = ['sensfunc', 'UVIS', 'polycorrect = False']
.
- pypeitpar_text(msglist)[source]
Prepare a text string with the pypeit par formatting.
- Parameters:
msglist (list) –
A list containing the pypeit parameter strings. The last element of the list must be the argument and the variable. For example, to print:
[sensfunc] [[UVIS]] polycorrect = False
you should set
msglist = ['sensfunc', 'UVIS', 'polycorrect = False']
.- Returns:
parstring – The parameter string
- Return type:
- reset(log=None, verbosity=None, colors=True, log_to_stderr=None)[source]
Reinitialize the object.
Needed so that there can be a default object for all modules, but also a dynamically defined log file.
- set_logfile_and_verbosity(scriptname, verbosity)[source]
Set the logfile name and verbosity level for a script run.
PypeIt scripts (with the exception of run_pypeit) default to verbosity level = 1. For certain scripts, having a more verbose output (with an accompanying log file) would be helpful for debugging purposes. This function provides the ability to set the
msgs
verbosity and create a log file for those certain scripts.Log filenames have the form scriptname_YYYYMMDD_HHMM.log to differentiate between different runs of the script. Timestamp is UT.
- exception pypeit.pypmsgs.PypeItBitMaskError[source]
Bases:
PypeItError
- exception pypeit.pypmsgs.PypeItDataModelError[source]
Bases:
PypeItError
- exception pypeit.pypmsgs.PypeItPathError[source]
Bases:
PypeItError