Skip to content

Commit

Permalink
Merge pull request #163 from ropensci/rm_logger
Browse files Browse the repository at this point in the history
Remove logging
  • Loading branch information
slager authored Oct 14, 2024
2 parents b5174b0 + 924b833 commit eec1d7c
Show file tree
Hide file tree
Showing 19 changed files with 59 additions and 259 deletions.
1 change: 0 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ Imports:
cli,
desc,
digest,
futile.logger,
knitr,
pkgbuild,
pkgload,
Expand Down
14 changes: 0 additions & 14 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -28,20 +28,6 @@ export(yml_remove_files)
export(yml_remove_objects)
export(yml_write)
importFrom(desc,desc)
importFrom(futile.logger,INFO)
importFrom(futile.logger,TRACE)
importFrom(futile.logger,appender.console)
importFrom(futile.logger,appender.file)
importFrom(futile.logger,appender.tee)
importFrom(futile.logger,flog.appender)
importFrom(futile.logger,flog.debug)
importFrom(futile.logger,flog.error)
importFrom(futile.logger,flog.fatal)
importFrom(futile.logger,flog.info)
importFrom(futile.logger,flog.logger)
importFrom(futile.logger,flog.threshold)
importFrom(futile.logger,flog.trace)
importFrom(futile.logger,flog.warn)
importFrom(knitr,knit)
importFrom(knitr,spin)
importFrom(rmarkdown,pandoc_available)
Expand Down
12 changes: 12 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
# DataPackageR (development version)

## Significant user-facing changes
* Remove functionality for logging to a logfile (#163)
* Remove 'log' argument from package_build() (#163)

## Unchanged
* User still sees same messages, warnings, and errors on the console
* Changes to data objects still automatically added to the data package NEWS.md
* For now, rendered output files still written to inst/extdata/Logfiles

## Maintenance
* Drop dependency on futile.logger package, which has not been updated since 2016.

# DataPackageR 0.16.1

## Minor user-facing improvements
Expand Down
44 changes: 14 additions & 30 deletions R/build.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
#'
#' @param packageName \code{character} path to package source directory. Defaults to the current path when NULL.
#' @param vignettes \code{logical} specify whether to build vignettes. Default FALSE.
#' @param log log level \code{INFO,WARN,DEBUG,FATAL}
#' @param deps \code{logical} should we pass data objects into subsequent scripts? Default TRUE
#' @param install \code{logical} automatically install and load the package after building. Default FALSE
#' @param ... additional arguments passed to \code{install.packages} when \code{install=TRUE}.
Expand All @@ -15,7 +14,6 @@
#' @importFrom rprojroot is_r_package
#' @importFrom rmarkdown pandoc_available
#' @importFrom yaml read_yaml
#' @importFrom futile.logger flog.logger flog.trace appender.file flog.debug flog.info flog.warn flog.error flog.fatal flog.appender flog.threshold INFO TRACE appender.console appender.tee
#' @importFrom knitr knit spin
#' @details Note that if \code{package_build} returns an error when rendering an \code{.Rmd}
#' internally, but that same \code{.Rmd} can be run successfully manually using \code{rmarkdown::render},
Expand Down Expand Up @@ -43,56 +41,45 @@
#' }
package_build <- function(packageName = NULL,
vignettes = FALSE,
log = INFO,
deps = TRUE,
install = FALSE,
...) {
.multilog_setup(LOGFILE = NULL)
# flog.appender(appender.console())
if (is.null(packageName)) {
packageName <- "."
# use normalizePath
package_path <- normalizePath(packageName, winslash = "/")
packageName <- basename(package_path)
# Is this a package root?
if (!is_r_package$find_file() == package_path) {
flog.fatal(paste0(package_path,
" is not an R package root directory"),
name = "console")
stop("exiting", call. = FALSE)
stop(paste(package_path, "is not an R package root directory"))
}
} else {
package_path <- normalizePath(packageName, winslash = "/")
if (!file.exists(package_path)) {
flog.fatal(paste0("Non existent package ", packageName), name = "console")
stop("exiting", call. = FALSE)
stop(paste("Non existent package", packageName))
}
packageName <- basename(package_path)
}
# This should always be a proper name of a directory, either current or a
# subdirectory
tryCatch({is_r_package$find_file(path = package_path)},
error = function(cond){
flog.fatal(paste0(
package_path,
" is not a valid R package directory beneath ",
getwd()
), name = "console")
stop("exiting", call. = FALSE)
stop(
paste(
package_path,
"is not a valid R package directory beneath",
getwd()
)
)
}
)

# Check that directory name matches package name
validate_pkg_name(package_path)

# Return success if we've processed everything
success <-
DataPackageR(arg = package_path, deps = deps)
ifelse(success,
.multilog_trace("DataPackageR succeeded"),
.multilog_warn("DataPackageR failed")
)
.multilog_trace("Building documentation")
# Process everything
DataPackageR(arg = package_path, deps = deps)

local({
on.exit({
if (packageName %in% names(utils::sessionInfo()$otherPkgs)){
Expand All @@ -101,7 +88,6 @@ package_build <- function(packageName = NULL,
})
roxygen2::roxygenize(package_path, clean = TRUE)
})
.multilog_trace("Building package")
location <- pkgbuild::build(path = package_path,
dest_path = dirname(package_path),
vignettes = vignettes,
Expand Down Expand Up @@ -142,10 +128,8 @@ validate_pkg_name <- function(package_path){
)$get("Package")
path_pkg_name <- basename(package_path)
if (desc_pkg_name != path_pkg_name){
err_msg <- paste("Data package name in DESCRIPTION does not match",
"name of the data package directory")
flog.fatal(err_msg, name = "console")
stop(err_msg, call. = FALSE)
stop(paste("Data package name in DESCRIPTION does not match",
"name of the data package directory"))
}
desc_pkg_name
}
21 changes: 2 additions & 19 deletions R/digests.R
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@

.compare_digests <- function(old_digest, new_digest) {
# Returns FALSE when any existing data has is changed, new data is added, or
# data is removed, else return TRUE. Use .multilog_trace for all changes since
# this is standard behavior during package re-build, and changes are already
# data is removed, else return TRUE. Changes are already
# output to the console by .qualify_changes()

old_digest[['DataVersion']] <- NULL
Expand All @@ -33,23 +32,7 @@
removed <- setdiff(names(old_digest), names(new_digest))
common <- intersect(names(old_digest), names(new_digest))
changed <- common[new_digest[common] != old_digest[common]]
out <- TRUE
for(name in changed){
.multilog_trace(paste(name, "has changed."))
out <- FALSE
}

for(name in removed){
.multilog_trace(paste(name, "was removed."))
out <- FALSE
}

for(name in added){
.multilog_trace(paste(name, "was added."))
out <- FALSE
}

return(out)
length(c(added, removed, changed)) == 0L
}

.combine_digests <- function(new, old) {
Expand Down
1 change: 0 additions & 1 deletion R/load_save.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
pkg_path = NULL) {
DataVersion <- validate_DataVersion(DataVersion)
.save_digest(new_data_digest, path = pkg_path)
.multilog_trace("Saving to data")
# TODO get the names of each data object and save them separately. Provide a
# function to load all.
for (i in seq_along(object_names)) {
Expand Down
57 changes: 0 additions & 57 deletions R/logger.R

This file was deleted.

Loading

0 comments on commit eec1d7c

Please sign in to comment.