cf-python icon indicating copy to clipboard operation
cf-python copied to clipboard

Utility to consolidate log messages of form f"X={X}"

Open sadielbartholomew opened this issue 4 years ago • 0 comments

Particularly in the field module, but also frequently elsewhere throughout the modules in the codebase, we have logging or error messages (often for debugging but not always) which name a variable and then print it's value, for example across these blocks from field (though not always contiguously so as to be condensable into one statement):

https://github.com/NCAS-CMS/cf-python/blob/af15b433ea88fb3cbb712bea6c5e5a0c24f88dff/cf/field.py#L480-L483

and https://github.com/NCAS-CMS/cf-python/blob/af15b433ea88fb3cbb712bea6c5e5a0c24f88dff/cf/field.py#L1724-L1735

These aren't necessarily troublesome and not usually user-facing (unless the user is hardcore and debugging), but to add flexibility of pretty-printed output (indentation, etc., even allowing for support of a machine-parsable output which can be queried rather than eyeballed for serious debugging) and reduce duplication it might be good to create a method that manages the logic of printing the name and value (and perhaps registering in some structure for such easy querying).

sadielbartholomew avatar Sep 02 '21 16:09 sadielbartholomew