cfdm.log_level

cfdm.log_level(*log_level)[source]

The minimal level of seriousness of log messages which are shown.

This can be adjusted to filter out potentially-useful log messages generated by cfdm at runtime, such that any messages marked as having a severity below the level set will not be reported.

For example, when set to 'WARNING' (or equivalently 1), all messages categorised as 'DEBUG' or 'INFO' will be supressed, and only warnings will emerge.

See https://ncas-cms.github.io/cfdm/tutorial.html#logging for a detailed breakdown on the levels and configuration possibilities.

The default level is 'WARNING' (1).

New in version (cfdm): 1.8.4

Parameters
log_level: str or int, optional

The new value of the minimal log severity level. This can be specified either as a string equal (ignoring case) to the named set of log levels or identifier ‘DISABLE’, or an integer code corresponding to each of these, namely:

  • 'DISABLE' (0);

  • 'WARNING' (1);

  • 'INFO' (2);

  • 'DETAIL' (3);

  • 'DEBUG' (-1).

Returns
str

The value prior to the change, or the current value if no new value was specified (or if one was specified but was not valid). Note the string name, rather than the equivalent integer, will always be returned.

Examples:

>>> log_level()  # get the current value
'WARNING'
>>> log_level('INFO')  # change the value to 'INFO'
'WARNING'
>>> log_level()
'INFO'
>>> log_level(0)  # set to 'DISABLE' via corresponding integer
'INFO'
>>> log_level()
'DISABLE'