diff --git a/DESCRIPTION b/DESCRIPTION index 5110d9a..61db21e 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -7,7 +7,7 @@ Description: the handler message to an 'ndjson' log file. No change in existing code is necessary to use this package, and should only require additions to fully leverage the power of the logging system. -Version: 2.2.2.9999 +Version: 2.3.0 Authors@R: c( person("Matthias", "Ollech", role = c("cre", "aut"), email = "ollech@gmx.com"), person("Ryan", "Price", role = c("fnd", "aut")) diff --git a/NEWS.md b/NEWS.md index f181a19..3a6ebfd 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,4 +1,4 @@ -# loggit2 (development version) +# loggit2 2.3.0 ## Breaking Changes * Custom `sanitizer`s and `unsanitizer`s are no longer supported. This decision was made because no active user is known, @@ -17,6 +17,7 @@ * All condition log handlers (e.g., `warning()`) allow `NA` for the parameter `.loggit`. If `NA`, the log level set by `set_log_level()` is used to determine if the condition should be logged. This is the new default behavior, but since the default log level is `"DEBUG"`, this should not change the behavior of existing code. * All `set_*` functions now return the previous value of the setting. +* The default settings can now be controlled by the system environment variables `FILE_LOGGIT2`, `TIMESTAMP_LOGGIT2`, `ECHO_LOGGIT2` and `LEVEL_LOGGIT2`. ## Bugfixes * `read_logs()` now correctly reads empty character values `""`, as in `{"key": ""}`. diff --git a/vignettes/articles/fork.rmd b/vignettes/articles/fork.rmd index 74bb956..37c01e3 100644 --- a/vignettes/articles/fork.rmd +++ b/vignettes/articles/fork.rmd @@ -40,7 +40,7 @@ loggit::stop("This is an error") #> Error in loggit::stop("This is an error"): This is an error ``` In `{loggit2}`, each condition handler shows the same call as its base equivalent. -```{r, error = TRUE, collapse = TRUE} +```{r, error = TRUE} base::message("This is another message") loggit2::message("This is another message") @@ -58,7 +58,7 @@ In `{loggit}`, there are no "condition log handlers" (i.e., functions that work write to the log) for `base::stopifnot()`. This makes the migration of existing code (without logs) unnecessarily complicated. In `loggit2`, this has been added: -```{r, error = TRUE, collapse = TRUE} +```{r, error = TRUE} base::stopifnot("TRUE is not true" = TRUE, "This is an error" = 3L < 1L, "This is another error" = FALSE) loggit2::stopifnot("TRUE is not true" = TRUE, "This is an error" = 3L < 1L, "This is another error" = FALSE) ``` @@ -102,7 +102,7 @@ f() ``` In `{loggit2}`, each condition handler shows the same call as its `{base}` equivalent. -```{r, error = TRUE, collapse = TRUE} +```{r, error = TRUE} f <- function() { base::message("This is another message") base::warning("This is another warning") diff --git a/vignettes/further_configurations.rmd b/vignettes/further_configurations.rmd index f30cac7..6376cb4 100644 --- a/vignettes/further_configurations.rmd +++ b/vignettes/further_configurations.rmd @@ -42,7 +42,7 @@ The configuration options of `loggit2` are described below. For details, refer t The log file can be set either via the environment variable `FILE_LOGGIT2`, the function `set_log_file()`, or the `logfile` argument of the logging functions `loggit()` and `with_loggit()`. The wrappers of the base R condition handler always use the session-wide configuration. -```{r, echo = -1, collapse = TRUE} +```{r, echo = -1} setwd(tempdir()) old_log <- loggit2::set_logfile(logfile = "logfile.log") loggit2::loggit( @@ -67,7 +67,7 @@ loggit2::set_logfile(old_log) ### Log level The log level can be set either via the environment variable `LEVEL_LOGGIT2` or the function `set_log_level()`. The `.loggit` argument can also be passed to the wrappers of the base R condition handler to enforce logging (`TRUE`) or suppress it (`FALSE`). The logging function `loggit()` can enforce logging through the `ignore_log_level` argument. `with_loggit()` allows setting a log level for the code block being executed. -```{r, error = TRUE, collapse = TRUE} +```{r, error = TRUE} old_log_lvl <- loggit2::set_log_level("INFO") loggit2::message("This message will be logged, since the log level is INFO.") loggit2::loggit( @@ -97,7 +97,7 @@ loggit2::set_log_level(old_log_lvl) ### Echo Whether log messages should also be output to `stdout` can be controlled via the environment variable `ECHO_LOGGIT2` or the function `set_echo()`. Additionally, all logging functions and wrappers of the base R condition handler allow direct control via the `echo` argument. -```{r, collapse = TRUE} +```{r} old_echo <- loggit2::set_echo(FALSE) loggit2::message("This message will not be logged, but it will be output to the console.") loggit2::message("This message will be logged and output to the console.", echo = TRUE) @@ -115,7 +115,7 @@ loggit2::set_echo(old_echo) ### Timestamp format The format of the timestamp can be controlled via the environment variable `TIMESTAMP_LOGGIT2` or the function `set_timestamp_format()`. -```{r, collapse = TRUE} +```{r} old_ts <- loggit2::set_timestamp_format("%H:%M:%S") loggit2::message("This message will be logged with a timestamp in the format HH:MM:SS.")