Skip to content

Commit

Permalink
Merge pull request #29 from shunsambongi/hotfix/log-appender
Browse files Browse the repository at this point in the history
Hotfix: logging
  • Loading branch information
shunsambongi authored Jul 22, 2020
2 parents 9f23ddd + 441ace4 commit 19b99bf
Show file tree
Hide file tree
Showing 9 changed files with 34 additions and 9 deletions.
7 changes: 4 additions & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: chex
Title: Run Checks
Version: 0.1.2
Version: 0.1.3
Authors@R:
person(given = "Shun",
family = "Sambongi",
Expand All @@ -26,10 +26,11 @@ Suggests:
logger,
mockery,
rmarkdown,
testthat
testthat,
withr
VignetteBuilder:
knitr
Encoding: UTF-8
LazyData: true
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.1.0
RoxygenNote: 7.1.1
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# chex 0.1.3

* Hotfix: fix package log_appender

# chex 0.1.2

* Bugfix: logging ignores formatting and uses result descriptions as-is.
Expand Down
16 changes: 16 additions & 0 deletions R/logging.R
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,19 @@ log_result <- function(result) {
}
invisible(result)
}

init_logging <- function() {
if (!requireNamespace("logger", quietly = TRUE)) {
return(invisible())
}

try(silent = TRUE, {
namespaces <- get(
"namespaces", envir = asNamespace("logger"), mode = "environment"
)
if (!exists("chex", namespaces)) {
logger::log_appender(identity, namespace = "chex")
}
})
invisible()
}
3 changes: 1 addition & 2 deletions R/zzz.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
.onLoad <- function(...) {
logger::log_appender(identity, namespace = "chex")
init_logging()
vctrs::s3_register("dplyr::filter", "chex_result")
}

2 changes: 1 addition & 1 deletion man/result.Rd

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

2 changes: 1 addition & 1 deletion man/run_check.Rd

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

2 changes: 1 addition & 1 deletion tests/testthat/test-result.R
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ test_that("equality works", {
test_that("aggregation works", {
len <- 20
every <- result(rep(TRUE, len), NA)
some <- vec_assign(every, (1:len) <= 10, result(FALSE, NA))
some <- result(c(rep(TRUE, len / 2), rep(FALSE, len / 2)), NA)
expect_length(every, len)
expect_length(some, len)
expect_true(any(every))
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-status.R
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ test_that("equality work", {
test_that("aggregation works", {
n <- 20
every <- status_(rep("PASS", n))
some <- vec_assign(every, (1:n) <= 10, FALSE)
some <- status_(c(rep("PASS", n / 2), rep("FAIL", n / 2)))
expect_length(every, n)
expect_length(some, n)

Expand Down
5 changes: 5 additions & 0 deletions vignettes/logging.Rmd
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
---
title: "Logging"
output: rmarkdown::html_vignette
vignette: >
%\VignetteIndexEntry{Logging}
%\VignetteEngine{knitr::rmarkdown}
%\VignetteEncoding{UTF-8}
---

```{r, include = FALSE}
Expand Down

0 comments on commit 19b99bf

Please sign in to comment.