diff --git a/DESCRIPTION b/DESCRIPTION index c140eaf..d9644cf 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,13 +1,15 @@ Type: Package Package: logger Title: A Lightweight, Modern and Flexible Logging Utility -Version: 0.4.1.9000 -Date: 2025-09-09 +Version: 0.4.1.9001 +Date: 2025-10-29 Authors@R: c( person("Gergely", "Daróczi", , "daroczig@rapporter.net", role = c("aut", "cre"), comment = c(ORCID = "0000-0003-3149-8537")), person("Hadley", "Wickham", , "hadley@posit.co", role = "aut", comment = c(ORCID = "0000-0003-4757-117X")), + person("Jonathan", "Carroll", , "rpkg@jcarroll.com.au", role = "ctb", + comment = c(ORCID = "0000-0002-1404-5264")), person("Spare Cores", role = "fnd"), person("System1", role = "fnd") ) @@ -31,6 +33,7 @@ Suggests: jsonlite, knitr, mirai (>= 1.3.0), + ntfy, pander, parallel, R.utils, @@ -54,4 +57,4 @@ Config/testthat/edition: 3 Config/testthat/parallel: TRUE Encoding: UTF-8 Roxygen: list(markdown = TRUE) -RoxygenNote: 7.3.2 +RoxygenNote: 7.3.3 diff --git a/NAMESPACE b/NAMESPACE index 5831162..baad7ee 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -18,6 +18,7 @@ export(appender_async) export(appender_console) export(appender_file) export(appender_kinesis) +export(appender_ntfy) export(appender_pushbullet) export(appender_slack) export(appender_stderr) diff --git a/NEWS.md b/NEWS.md index 107c94a..36194a1 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,9 @@ # logger 0.4.1.9000 (development version) +New features and quality of life improvements: + +* Added `appender_ntfy()` to use {ntfy} as an appender (#240, @jonocarroll) + # logger 0.4.1 (2025-09-08) New features and quality of life improvements: diff --git a/R/appenders.R b/R/appenders.R index 86e1de5..3e5d8a6 100644 --- a/R/appenders.R +++ b/R/appenders.R @@ -232,6 +232,34 @@ appender_pushbullet <- function(...) { } +#' Send log messages to ntfy +#' @param title notification title +#' @param tags emoji (or general tag) for notification. See [ntfy::emoji] +#' @param ... extra parameters passed to [ntfy::ntfy_send] such as +#' `priority`, `topic`, etc. +#' @details Configure server and topic via environment variables. See +#' [ntfy::ntfy_topic()] for details +#' @export +#' @note This functionality depends on the \pkg{ntfy} package. +#' @family log_appenders +#' @export +appender_ntfy <- function(title = "{logger}", + tags = c("memo"), + ...) { + fail_on_missing_package("ntfy") + force(title) + force(tags) + + structure( + function(lines) { + ntfy::ntfy_send(title = title, tags = tags, message = paste(lines, sep = "\n"), ...) + }, + generator = deparse(match.call()) + ) +} + + + #' Send log messages to a Telegram chat #' @param chat_id Unique identifier for the target chat or username of #' the target channel (in the format @channelusername) diff --git a/man/appender_async.Rd b/man/appender_async.Rd index 821e17c..ed6dd38 100644 --- a/man/appender_async.Rd +++ b/man/appender_async.Rd @@ -68,6 +68,7 @@ Other log_appenders: \code{\link{appender_console}()}, \code{\link{appender_file}()}, \code{\link{appender_kinesis}()}, +\code{\link{appender_ntfy}()}, \code{\link{appender_pushbullet}()}, \code{\link{appender_slack}()}, \code{\link{appender_stdout}()}, diff --git a/man/appender_console.Rd b/man/appender_console.Rd index eca4d83..68eb287 100644 --- a/man/appender_console.Rd +++ b/man/appender_console.Rd @@ -20,6 +20,7 @@ Other log_appenders: \code{\link{appender_async}()}, \code{\link{appender_file}()}, \code{\link{appender_kinesis}()}, +\code{\link{appender_ntfy}()}, \code{\link{appender_pushbullet}()}, \code{\link{appender_slack}()}, \code{\link{appender_stdout}()}, diff --git a/man/appender_file.Rd b/man/appender_file.Rd index 554815e..e4daa28 100644 --- a/man/appender_file.Rd +++ b/man/appender_file.Rd @@ -78,6 +78,7 @@ Other log_appenders: \code{\link{appender_async}()}, \code{\link{appender_console}()}, \code{\link{appender_kinesis}()}, +\code{\link{appender_ntfy}()}, \code{\link{appender_pushbullet}()}, \code{\link{appender_slack}()}, \code{\link{appender_stdout}()}, diff --git a/man/appender_kinesis.Rd b/man/appender_kinesis.Rd index 6215efb..253e651 100644 --- a/man/appender_kinesis.Rd +++ b/man/appender_kinesis.Rd @@ -24,6 +24,7 @@ Other log_appenders: \code{\link{appender_async}()}, \code{\link{appender_console}()}, \code{\link{appender_file}()}, +\code{\link{appender_ntfy}()}, \code{\link{appender_pushbullet}()}, \code{\link{appender_slack}()}, \code{\link{appender_stdout}()}, diff --git a/man/appender_ntfy.Rd b/man/appender_ntfy.Rd new file mode 100644 index 0000000..0aa49d8 --- /dev/null +++ b/man/appender_ntfy.Rd @@ -0,0 +1,40 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/appenders.R +\name{appender_ntfy} +\alias{appender_ntfy} +\title{Send log messages to ntfy} +\usage{ +appender_ntfy(title = "{logger}", tags = c("memo"), ...) +} +\arguments{ +\item{title}{notification title} + +\item{tags}{emoji (or general tag) for notification. See \link[ntfy:emoji]{ntfy::emoji}} + +\item{...}{extra parameters passed to \link[ntfy:ntfy_send]{ntfy::ntfy_send} such as +\code{priority}, \code{topic}, etc.} +} +\description{ +Send log messages to ntfy +} +\details{ +Configure server and topic via environment variables. See +\code{\link[ntfy:ntfy_topic]{ntfy::ntfy_topic()}} for details +} +\note{ +This functionality depends on the \pkg{ntfy} package. +} +\seealso{ +Other log_appenders: +\code{\link{appender_async}()}, +\code{\link{appender_console}()}, +\code{\link{appender_file}()}, +\code{\link{appender_kinesis}()}, +\code{\link{appender_pushbullet}()}, +\code{\link{appender_slack}()}, +\code{\link{appender_stdout}()}, +\code{\link{appender_syslog}()}, +\code{\link{appender_tee}()}, +\code{\link{appender_telegram}()} +} +\concept{log_appenders} diff --git a/man/appender_pushbullet.Rd b/man/appender_pushbullet.Rd index cd20112..2888f5e 100644 --- a/man/appender_pushbullet.Rd +++ b/man/appender_pushbullet.Rd @@ -24,6 +24,7 @@ Other log_appenders: \code{\link{appender_console}()}, \code{\link{appender_file}()}, \code{\link{appender_kinesis}()}, +\code{\link{appender_ntfy}()}, \code{\link{appender_slack}()}, \code{\link{appender_stdout}()}, \code{\link{appender_syslog}()}, diff --git a/man/appender_slack.Rd b/man/appender_slack.Rd index 81f283b..3b9f463 100644 --- a/man/appender_slack.Rd +++ b/man/appender_slack.Rd @@ -39,6 +39,7 @@ Other log_appenders: \code{\link{appender_console}()}, \code{\link{appender_file}()}, \code{\link{appender_kinesis}()}, +\code{\link{appender_ntfy}()}, \code{\link{appender_pushbullet}()}, \code{\link{appender_stdout}()}, \code{\link{appender_syslog}()}, diff --git a/man/appender_stdout.Rd b/man/appender_stdout.Rd index 6f4dcdd..59c3bd2 100644 --- a/man/appender_stdout.Rd +++ b/man/appender_stdout.Rd @@ -18,6 +18,7 @@ Other log_appenders: \code{\link{appender_console}()}, \code{\link{appender_file}()}, \code{\link{appender_kinesis}()}, +\code{\link{appender_ntfy}()}, \code{\link{appender_pushbullet}()}, \code{\link{appender_slack}()}, \code{\link{appender_syslog}()}, diff --git a/man/appender_syslog.Rd b/man/appender_syslog.Rd index d8f697b..080fac8 100644 --- a/man/appender_syslog.Rd +++ b/man/appender_syslog.Rd @@ -9,7 +9,7 @@ appender_syslog(identifier, ...) \arguments{ \item{identifier}{A string identifying the process.} -\item{...}{Further arguments passed on to \code{\link[rsyslog:syslog]{rsyslog::open_syslog()}}.} +\item{...}{Further arguments passed on to \code{\link[rsyslog:open_syslog]{rsyslog::open_syslog()}}.} } \value{ function taking \code{lines} argument @@ -34,6 +34,7 @@ Other log_appenders: \code{\link{appender_console}()}, \code{\link{appender_file}()}, \code{\link{appender_kinesis}()}, +\code{\link{appender_ntfy}()}, \code{\link{appender_pushbullet}()}, \code{\link{appender_slack}()}, \code{\link{appender_stdout}()}, diff --git a/man/appender_tee.Rd b/man/appender_tee.Rd index f074ae5..e29d3ec 100644 --- a/man/appender_tee.Rd +++ b/man/appender_tee.Rd @@ -41,6 +41,7 @@ Other log_appenders: \code{\link{appender_console}()}, \code{\link{appender_file}()}, \code{\link{appender_kinesis}()}, +\code{\link{appender_ntfy}()}, \code{\link{appender_pushbullet}()}, \code{\link{appender_slack}()}, \code{\link{appender_stdout}()}, diff --git a/man/appender_telegram.Rd b/man/appender_telegram.Rd index 789ac0b..61e8242 100644 --- a/man/appender_telegram.Rd +++ b/man/appender_telegram.Rd @@ -34,6 +34,7 @@ Other log_appenders: \code{\link{appender_console}()}, \code{\link{appender_file}()}, \code{\link{appender_kinesis}()}, +\code{\link{appender_ntfy}()}, \code{\link{appender_pushbullet}()}, \code{\link{appender_slack}()}, \code{\link{appender_stdout}()}, diff --git a/man/colorize_by_log_level.Rd b/man/colorize_by_log_level.Rd index 54322ac..fc0f608 100644 --- a/man/colorize_by_log_level.Rd +++ b/man/colorize_by_log_level.Rd @@ -23,7 +23,7 @@ or grayscale color scheme. The greyscale theme assumes a dark background on the terminal. } \examples{ -\dontshow{if (requireNamespace("crayon")) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} +\dontshow{if (requireNamespace("crayon")) withAutoprint(\{ # examplesIf} cat(colorize_by_log_level("foobar", FATAL), "\n") cat(colorize_by_log_level("foobar", ERROR), "\n") cat(colorize_by_log_level("foobar", WARN), "\n") diff --git a/man/layout_glue_colors.Rd b/man/layout_glue_colors.Rd index f26e102..4ae3bf4 100644 --- a/man/layout_glue_colors.Rd +++ b/man/layout_glue_colors.Rd @@ -52,7 +52,7 @@ with \code{\link[=colorize_by_log_level]{colorize_by_log_level()}} and the messa This functionality depends on the \pkg{crayon} package. } \examples{ -\dontshow{if (requireNamespace("crayon")) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} +\dontshow{if (requireNamespace("crayon")) withAutoprint(\{ # examplesIf} log_layout(layout_glue_colors) log_threshold(TRACE) log_info("Starting the script...") diff --git a/man/logger-package.Rd b/man/logger-package.Rd index e2054b7..79ea0a2 100644 --- a/man/logger-package.Rd +++ b/man/logger-package.Rd @@ -27,6 +27,7 @@ Authors: Other contributors: \itemize{ + \item Jonathan Carroll \email{rpkg@jcarroll.com.au} (\href{https://orcid.org/0000-0002-1404-5264}{ORCID}) [contributor] \item Spare Cores [funder] \item System1 [funder] }