Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix remaining check warnings from PEcAn.logger (fixes #2814) #2815

Merged
merged 33 commits into from
Jul 21, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
b9143c6
Update DESCRIPTION
moki1202 Jun 30, 2021
0c0bf6a
Update logger.R
moki1202 Jun 30, 2021
d89c1e1
Update print2string.R
moki1202 Jun 30, 2021
67c0bf7
Update logifnot.R
moki1202 Jun 30, 2021
9132a97
Update base/logger/DESCRIPTION
moki1202 Jul 1, 2021
f697fb0
Update DESCRIPTION
moki1202 Jul 1, 2021
80ac298
Update logifnot.R
moki1202 Jul 1, 2021
79726d2
Merge branch 'develop' into patch-14
infotroph Jul 3, 2021
da84d6b
Update base/logger/DESCRIPTION
moki1202 Jul 3, 2021
cfd1680
Update base/logger/R/logifnot.R
moki1202 Jul 3, 2021
f1b6c26
Update base/logger/R/logifnot.R
moki1202 Jul 3, 2021
3efa320
Update base/logger/R/logifnot.R
moki1202 Jul 3, 2021
b8f3de7
Update base/logger/R/logifnot.R
moki1202 Jul 3, 2021
1e9b1b4
Update base/logger/R/logifnot.R
moki1202 Jul 3, 2021
df4873d
Update base/logger/R/logifnot.R
moki1202 Jul 3, 2021
f0427a7
Delete check_conditions.Rd
moki1202 Jul 3, 2021
b4b380e
Delete is_definitely_true.Rd
moki1202 Jul 3, 2021
a9e9e15
Update base/logger/R/logifnot.R
moki1202 Jul 3, 2021
0716cd2
changed roxygen comments to R comments
moki1202 Jul 3, 2021
c9baaf4
Update logifnot.R
moki1202 Jul 3, 2021
548c1a0
automated documentation update
Jul 3, 2021
4bde110
quiet note about dump.log
infotroph Jul 3, 2021
f4d4f28
add myself as contributor, fix link
infotroph Jul 3, 2021
cbeab65
Update DESCRIPTION
moki1202 Jul 4, 2021
7bc8820
Merge pull request #4 from infotroph/logger-check-tweaks
moki1202 Jul 4, 2021
358c953
Create NEWS.md
moki1202 Jul 4, 2021
05c60c8
Update base/logger/NEWS.md
moki1202 Jul 4, 2021
c80d222
Update base/logger/R/logger.R
moki1202 Jul 4, 2021
5055e47
Update DESCRIPTION
moki1202 Jul 9, 2021
3c35b4e
Delete Rcheck_reference.log
moki1202 Jul 14, 2021
ae785b1
Update base/logger/DESCRIPTION
moki1202 Jul 15, 2021
dc6b1f3
Merge branch 'develop' into patch-14
infotroph Jul 15, 2021
dd5644e
Merge branch 'develop' into patch-14
infotroph Jul 15, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 10 additions & 6 deletions base/logger/DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
Package: PEcAn.logger
Title: Logger functions for PEcAn
Title: Logger Functions for PEcAn
Version: 1.7.1
Date: 2019-09-05
Authors@R: c(person("Rob","Kooper"),
person("Alexey", "Shiklomanov"))
Author: Rob Kooper, Alexey Shiklomanov
Maintainer: Alexey Shiklomanov <ashiklom@bu.edu>
Authors@R: c(person("Rob", "Kooper", role = c("aut", "cre"),
email = "kooper@illinois.edu"),
person("Alexey", "Shiklomanov", role = c("aut"),
email = "ashiklom@bu.edu"),
person("Shashank", "Singh", role = c("aut"),
email = "shashanksingh819@gmail.com"),
person("Chris", "Black", role = c("ctb")))
Description: Special logger functions for tracking execution status and the environment.
BugReports: https://github.com/PecanProject/pecan/issues
Imports: utils
Suggests: testthat
License: BSD_3_clause + file LICENSE
Encoding: UTF-8
LazyData: true
RoxygenNote: 7.0.2
Roxygen: list(markdown = TRUE)
9 changes: 9 additions & 0 deletions base/logger/NEWS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# PEcAn.logger 1.7.1.9000
## Fixed

moki1202 marked this conversation as resolved.
Show resolved Hide resolved
* Logger calls no longer create a stray `dump.log` object in the global environment

#PEcAn.logger 1.7.1

* All changes in 1.7.1 and earlier were recorded in a single file for all of the PEcAn packages; please see
https://github.com/PecanProject/pecan/blob/v1.7.1/CHANGELOG.md for details.
30 changes: 13 additions & 17 deletions base/logger/R/logger.R
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,9 @@ logger.error <- function(msg, ...) {
##' Prints an severe message and stops execution.
##'
##' This function will print a message and stop execution of the code. This
##' should only be used if the application should terminate.
##' should only be used if the application should terminate.
##'
##' set \code{\link{logger.setQuitOnSevere(FALSE)}}. To avoid terminating
##' set \code{\link{logger.setQuitOnSevere}(FALSE)} to avoid terminating
##' the session. This is set by default to TRUE if interactive or running
##' inside Rstudio.
##'
Expand Down Expand Up @@ -140,11 +140,10 @@ logger.severe <- function(msg, ..., wrap = TRUE) {
##' }
logger.message <- function(level, msg, ..., wrap = TRUE) {
if (logger.getLevelNumber(level) >= .utils.logger$level) {
dump.frames(dumpto = "dump.log")
calls <- names(dump.log)
calls <- utils::limitedLabels(sys.calls())
calls <- calls[!grepl("^(#[0-9]+: )?(PEcAn\\.logger::)?logger", calls)]
calls <- calls[!grepl("(severe|error|warn|info|debug)ifnot", calls)]
func <- sub("\\(.*", "", tail(calls, 1))
func <- sub("\\(.*", "", utils::tail(calls, 1))
if (length(func) == 0) {
func <- "console"
}
Expand Down Expand Up @@ -191,18 +190,15 @@ logger.setLevel <- function(level) {
} # logger.setLevel


##' Returns numeric value for string
##'
##' Given the string representation this will return the numeric value
##' ALL = 0
##' DEBUG = 10
##' INFO = 20
##' WARN = 30
##' ERROR = 40
##' ALL = 99
##'
##' @return level the level of the message
##' @author Rob Kooper
## Given the string representation this will return the numeric value
## DEBUG = 10
## INFO = 20
## WARN = 30
## ERROR = 40
## ALL = 99
##
##@return level the level of the message
##@author Rob Kooper
logger.getLevelNumber <- function(level) {
if (toupper(level) == "ALL") {
return(0)
Expand Down
16 changes: 9 additions & 7 deletions base/logger/R/logifnot.R
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
#' Logger message if conditions are not met
#'
#' Similar to [base::stopifnot], but allows you to use a custom message and
#' Similar to [base::stopifnot], but allows you to use a custom message and
#' logger level. If all conditions are `TRUE`, silently exit.
#'
#' Conditions can be vectorized, or can return non-logical values.The
#' underlying function automatically applies `isTRUE(all(.))` to the
#' Conditions can be vectorized, or can return non-logical values.The
#' underlying function automatically applies `isTRUE(all(.))` to the
#' conditions.
#'
#' @param msg Logger message to write, as a single character string.
#' @param ... Conditions to evaluate
#' @param ... Conditions to evaluate
#' @return Invisibly, `TRUE` if conditions are met, `FALSE` otherwise
#' @examples
#' a <- 1:5
Expand All @@ -18,7 +18,9 @@
#' warnifnot("I would prefer it if you used lists.", is.list(a), is.list(b))
#' errorifnot("You should definitely use lists.", is.list(a), is.list(b))
#' try({
#' severeifnot("I absolutely cannot deal with the fact that something is not a list.", is.list(a), is.list(b))
#' severeifnot("I cannot deal with the fact that something is not a list.",
#' is.list(a),
#' is.list(b))
#' })
#' @export
severeifnot <- function(msg, ...) {
Expand Down Expand Up @@ -73,14 +75,14 @@ debugifnot <- function(msg, ...) {
}
}

#' Check a list of conditions
# Check a list of conditions
check_conditions <- function(...) {
dots <- list(...)
conditions <- vapply(dots, is_definitely_true, logical(1))
all(conditions)
}

#' Robust logical check
# Robust logical check
is_definitely_true <- function(x) {
if (is.null(x) || length(x) == 0 || !is.logical(x)) {
return(FALSE)
Expand Down
2 changes: 1 addition & 1 deletion base/logger/R/print2string.R
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@
#' logger.debug("Current status:\n", print2string(df, row.names = FALSE), wrap = FALSE)
#' @export
print2string <- function(x, ...) {
cout <- capture.output(print(x, ...))
cout <- utils::capture.output(print(x, ...))
paste(cout, collapse = "\n")
}
11 changes: 0 additions & 11 deletions base/logger/man/check_conditions.Rd

This file was deleted.

11 changes: 0 additions & 11 deletions base/logger/man/is_definitely_true.Rd

This file was deleted.

23 changes: 0 additions & 23 deletions base/logger/man/logger.getLevelNumber.Rd

This file was deleted.

2 changes: 1 addition & 1 deletion base/logger/man/logger.severe.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion base/logger/man/severeifnot.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

87 changes: 0 additions & 87 deletions base/logger/tests/Rcheck_reference.log

This file was deleted.