base: logging enhancements: multiple debug output levels
Per recent discussion on the dev mailing list, implement support for multiple levels of debug logging support.
Link to discussion threads:
- https://lists.macports.org/pipermail/macports-dev/2021-May/043502.html
- https://lists.macports.org/pipermail/macports-dev/2021-June/043542.html
Corresponding work for macports-ports: PR 11184 - base support: logging enhancements: multiple debug output levels
Update: This is working!
There's still some cleanup to do, but this is starting to approach a finished state:
- Regression Testing: Need to validate various touch points, such as
packageall.tclandportindex.tcl. - Automated Tests: Additional test cases may be needed/desired; still TBD though.
But looking good overall.
Thoughts/comments welcome, and appreciated!
Example output, with and without this PR, to illustrate the impact.
Current state, without:
$ port -d info --line --fullname --description mpich
DEBUG: Changing to port directory: /opt/local/var/macports/sources/rsync.macports.org/macports/release/tarballs/ports/science/mpich
DEBUG: OS darwin/17.7.0 (macOS 10.13.6) arch i386
DEBUG: Sourcing PortGroup active_variants 1.1 from /opt/local/var/macports/sources/rsync.macports.org/macports/release/tarballs/ports/_resources/port1.0/group/active_variants-1.1.tcl
DEBUG: GCC versions for Darwin 17 i386 - 5 6 7 8 9 10 11 devel
DEBUG: Clang versions for Darwin 17 i386 - 5.0 6.0 7.0 8.0 9.0 10 11 devel
DEBUG: Sourcing PortGroup compilers 1.0 from /opt/local/var/macports/sources/rsync.macports.org/macports/release/tarballs/ports/_resources/port1.0/group/compilers-1.0.tcl
DEBUG: Sourcing PortGroup mpiutil 1.0 from /opt/local/var/macports/sources/rsync.macports.org/macports/release/tarballs/ports/_resources/port1.0/group/mpiutil-1.0.tcl
DEBUG: universal_variant is false, so not adding the default universal variant
DEBUG: Running callback portconfigure::add_automatic_compiler_dependencies
DEBUG: Finished running callback portconfigure::add_automatic_compiler_dependencies
DEBUG: Running callback portbuild::add_automatic_buildsystem_dependencies
DEBUG: Finished running callback portbuild::add_automatic_buildsystem_dependencies
DEBUG: Running callback portstartupitem::add_notes
DEBUG: Finished running callback portstartupitem::add_notes
DEBUG: Running callback compilers::add_fortran_legacy_support
DEBUG: Finished running callback compilers::add_fortran_legacy_support
mpich @3.4.2 Message Passing Interface (MPI) Library
With the changes, at standard debug:
$ port -d info --line --fullname --description mpich
DEBUG: Changing to port directory: /opt/macports-debug3/var/macports/sources/rsync.macports.org/macports/release/tarballs/ports/science/mpich
DEBUG: OS darwin/17.7.0 (macOS 10.13.6) arch i386
DEBUG: GCC versions for Darwin 17 i386 - 5 6 7 8 9 10 11 devel
DEBUG: Clang versions for Darwin 17 i386 - 5.0 6.0 7.0 8.0 9.0 10 11 devel
mpich @3.4.2 Message Passing Interface (MPI) Library
With the changes, at debug level 3:
$ port -3 info --line --fullname --description mpich
DEBUG: Changing to port directory: /opt/macports-debug3/var/macports/sources/rsync.macports.org/macports/release/tarballs/ports/science/mpich
DEBUG: OS darwin/17.7.0 (macOS 10.13.6) arch i386
DEBUG1: Sourcing PortGroup active_variants 1.1 from /opt/macports-debug3/var/macports/sources/rsync.macports.org/macports/release/tarballs/ports/_resources/port1.0/group/active_variants-1.1.tcl
DEBUG: GCC versions for Darwin 17 i386 - 5 6 7 8 9 10 11 devel
DEBUG: Clang versions for Darwin 17 i386 - 5.0 6.0 7.0 8.0 9.0 10 11 devel
DEBUG1: Sourcing PortGroup compilers 1.0 from /opt/macports-debug3/var/macports/sources/rsync.macports.org/macports/release/tarballs/ports/_resources/port1.0/group/compilers-1.0.tcl
DEBUG1: Sourcing PortGroup mpiutil 1.0 from /opt/macports-debug3/var/macports/sources/rsync.macports.org/macports/release/tarballs/ports/_resources/port1.0/group/mpiutil-1.0.tcl
DEBUG1: universal_variant is false, so not adding the default universal variant
DEBUG1: Running callback portconfigure::add_automatic_compiler_dependencies
DEBUG1: Finished running callback portconfigure::add_automatic_compiler_dependencies
DEBUG1: Running callback portbuild::add_automatic_buildsystem_dependencies
DEBUG1: Finished running callback portbuild::add_automatic_buildsystem_dependencies
DEBUG1: Running callback portstartupitem::add_notes
DEBUG1: Finished running callback portstartupitem::add_notes
DEBUG1: Running callback compilers::add_fortran_legacy_support
DEBUG1: Finished running callback compilers::add_fortran_legacy_support
mpich @3.4.2 Message Passing Interface (MPI) Library
Overall, this PR provides plenty of other opportunities to reduce the verbosity of standard Debug output, particularly in our various PortGroups. But even with just the changes limited to base, we've already cut down significantly on our per-port output.
Having 4 levels of debug seems a bit excessive to me. I would have thought that say 3 would easily be enough granularity? I also find having level ‘0’ called debug, whilst 1-3 called debugN a little confusing. I would personally suggest making debug and debug1 the same level (so just make debug an alias to debug1 for compatibility) and then have debug2 and debug3 for two increasingly more detailed levels.
Having 4 levels of debug seems a bit excessive to me. I would have thought that say 3 would easily be enough granularity? I also find having level ‘0’ called debug, whilst 1-3 called debugN a little confusing. I would personally suggest making debug and debug1 the same level (so just make debug an alias to debug1 for compatibility) and then have debug2 and debug3 for two increasingly more detailed levels.
Sure, and three levels isn't set in stone; that was merely an arbitrary choice to start with.
Overall, this effort is still evolving, and the goal is to support logging based on namespaces/packages - similar to Python and Java - to allow more control over output and levels. (Per recommendations by folks on the mailing list.)
The latter hasn't been implemented yet, but watch this space.
Further thoughts/comments/suggestions welcome!
Relative to namespace/package logging, I'm currently evaluating the TCL logger package, to avoid reinventing the wheel. Based on a cursory look, it may provide a nice foundation for what we're trying to accomplish.
If anyone has any experience with that package - or if there's a better option - please let me know!
Having 4 levels of debug seems a bit excessive to me. I would have thought that say 3 would easily be enough granularity?
4 levels is how many Fink has, IIRC...
This PR has been changed to ready-for-review, with the caveat that merge conflicts need to be resolved. (Will try to get to that over the next few days.)
Relative to namespace-scoped logging - something not currently included - I'm wondering if we should shelve that at this point?
Reason being, we'd need to support a way to selectively set logging levels per-namespace. (Presumably via some type of config file, such as macports.conf.) And that adds a whole new level of complexity. Not to mention the question of whether that would ever be taken advantage of.
Relative to namespace-scoped logging - something not currently included - I'm wondering if we should shelve that at this point?
Yeah, probably worth saving that for a separate PR.