cf.log_level¶
-
cf.
log_level
(*arg)[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 equivalently1
), all messages categorised as'DEBUG'
or'INFO'
will be suppressed, 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
See also
- Parameters
- log_level:
str
orint
orConstant
, 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
).
- log_level:
- Returns
Constant
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
>>> cf.log_level() <CF Constant: 'WARNING'> >>> print(cf.log_level()) WARNING >>> str(cf.log_level()) 'WARNING'
>>> old = cf.log_level('INFO') >>> cf.log_level() <CF Constant: 'WARNING'> >>> cf.log_level(old) <CF Constant: 'INFO'> >>> cf.log_level() <CF Constant: 'WARNING'>
Use as a context manager:
>>> print(cf.log_level()) WARNING >>> with cf.log_level('DETAIL'): ... print(cf.log_level(), cf.log_level(-1), cf.log_level()) ... DETAIL DETAIL DEBUG >>> print(cf.log_level()) WARNING