Logging

Curie prints a summary of what each fit computed and which data it kept or dropped through console messages of the form [LEVEL] Class.method: message (see Fit Reporting Conventions for the conventions). Three functions control the output:

curie.set_log_level(level)[source]

Set the console message level

Controls which curie messages are printed to the console. Messages of the given level and above are shown. The default level is ‘INFO’, which shows per-fit summary lines and warnings; ‘DEBUG’ additionally shows each dropped peak or count with the threshold that removed it; ‘WARNING’ shows only likely result-changing messages; ‘ERROR’ silences everything except messages accompanying raised exceptions.

This affects the console only; log files created with ci.log_to() keep their own level.

Parameters:
levelstr

One of ‘DEBUG’, ‘INFO’, ‘WARNING’, ‘ERROR’ (case-insensitive), or a numeric level from the logging module.

Examples

>>> ci.set_log_level('DEBUG')
>>> ci.set_log_level('INFO')
curie.quiet_warnings()[source]

Silence curie’s console messages

One-call opt-out of curie’s default console output: raises the console level to ‘ERROR’, silencing both the routine INFO summary lines and WARNING messages. Errors accompanying raised exceptions are still shown. To keep warnings but silence the routine lines, use ci.set_log_level('WARNING') instead. Log files created with ci.log_to() are unaffected.

Examples

>>> ci.quiet_warnings()
>>> ci.set_log_level('INFO')  # restore the default
curie.log_to(filename, level='INFO', mode='overwrite')[source]

Write curie’s messages to a log file

Adds a log file receiving curie’s messages at the given level, independent of the console level (e.g. a ‘DEBUG’ file under a quiet console). By default an existing file at the same path is overwritten, since analysis scripts are typically re-run many times; pass mode='append' to accumulate runs instead. Calling log_to again with the same path replaces the previous file handler rather than duplicating messages.

Parameters:
filenamestr

Path of the log file.

levelstr, optional

Minimum message level written to the file: ‘DEBUG’, ‘INFO’, ‘WARNING’ or ‘ERROR’. Default ‘INFO’.

modestr, optional

‘overwrite’ (default) or ‘append’. The open()-style spellings ‘w’ and ‘a’ are also accepted.

Examples

>>> ci.log_to('analysis.log')
>>> ci.log_to('debug.log', level='DEBUG', mode='append')