Initially discussed in #3970, moving here for more planning before implementation: PEcAn.utils::read.output is very chatty by default, issuing lots of messages about routine behavior that get repeated as it handles each file even when reading a directory of thousands.
I propose the default behavior should be:
- print_summary = FALSE
- verbose = FALSE, as currently
- verbose = FALSE should additionally suppress all messages that are reporting documented behavior that it's safe to assume is what the user intended:
- "missing [start/end] year"
- "No start or end year provided"
- "Reading the following files"
- "Variables not specified. Reading output for all variables"
- These messages indicate directory contents that might not be what the user expected, so I can see a case for displaying them even when verbose = FALSE:
- "netCDF files for other years present"
- "No files found. Returning all NA"
In #3970 I had proposed approximating this by adding
if (!isTRUE(verbose)) {
loglevel <- PEcAn.logger::logger.setLevel("WARN")
on.exit(PEcAn.logger::logger.setLevel(loglevel), add = TRUE)
}
to the top of the function so that all the DEBUG and INFO messages are suppressed by default, but there are at least three reasons that's not by itself a full solution:
- The
print_summary output is implemented as a logger.info call, so it would make print_summary only work in verbose mode.
- Most of the debug messages are already written as
if (!verbose) PEcAn.logger::logger.debug(...), so suppressing the other ones via logger levels creates a needless inconsistency.
- Many of the
read.output unit tests rely on checking for the messages I'm proposing to suppress. @divine7022 pointed out that we could add verbose=TRUE to those tests as a quick workaround, but I submit the tests ought to be rewritten to check the return value (which is what matters most!) instead of the messages.
Initially discussed in #3970, moving here for more planning before implementation: PEcAn.utils::read.output is very chatty by default, issuing lots of messages about routine behavior that get repeated as it handles each file even when reading a directory of thousands.
I propose the default behavior should be:
In #3970 I had proposed approximating this by adding
to the top of the function so that all the DEBUG and INFO messages are suppressed by default, but there are at least three reasons that's not by itself a full solution:
print_summaryoutput is implemented as a logger.info call, so it would make print_summary only work in verbose mode.if (!verbose) PEcAn.logger::logger.debug(...), so suppressing the other ones via logger levels creates a needless inconsistency.read.outputunit tests rely on checking for the messages I'm proposing to suppress. @divine7022 pointed out that we could addverbose=TRUEto those tests as a quick workaround, but I submit the tests ought to be rewritten to check the return value (which is what matters most!) instead of the messages.