Logging enhancements

Open
#35 0 comments 0 reactions 1 assignee View on GitHub

@sadielbartholomew is already working on this.

Since May 19, 2020.

Assessment

This issue has not been assessed yet.

Description

enhancement

Follow-on from #31. Now the infrastructure for logging is in place, we can make good use of it with some extensions [feel free to add to this listing, anyone!]:

  • #31 did not add new logging calls, it simply replaced print calls existing at that point, which only existed on any equals methods & read or write functions. We should:

    • add meaningful messages across the codebase at applicable levels;
    • add a verbose kwarg to any function that ends up with a significant amount of log calls.
  • Improved display in log calls of objects for readability. For example, using pprint.pformat to print dictionary or list structures with an item per line, to make it easy to pick out a particular item especially where the structure has many items so it would otherwise be difficult. I have already changed a few messages in read_write.netcdf.netcdfread as such, e.g:

    https://github.com/NCAS-CMS/cfdm/blob/11fd0797532b8d924ffd5e91b561f0a6b9b43187/cfdm/read_write/netcdf/netcdfread.py#L670-L673

  • Currently log messages go, as the equivalent print() statements did, to STDOUT as pure messages i.e. no extra metadata such as datetime stamps are included, just log level, logger name, & the message itself. However I think it would be beneficial to have at least one new handler to provide (all logging messages plus) (date)time stamps, calls made by the user, and exceptions which get raised outside of the logging system.

    I think a file handler is best such that the user can specify a path where a named dedicated log file gets written out (& rolled if there is the potential for it to get large enough) with every possible detail (i.e. set cfdm.LOG_LEVEL('DEBUG') for that handler). This would be great for user support & debugging purposes.

    • for this handler, add functionality to print timestamped calls that are run by the user (not just the log messages themselves).
Dominant language
Python
Stars
32
Forks
14
Avg merge
3d 20h
Merged PRs (30d)
1

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from NCAS-CMS/cfdm

All issues in NCAS-CMS/cfdm

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.