Skip to content

Commit

Permalink
Merge branch 'main' of github.com:daroczig/logger
Browse files Browse the repository at this point in the history
  • Loading branch information
daroczig committed Jan 24, 2025
2 parents 54b2dcc + 4d6ddb4 commit 2b2cf94
Show file tree
Hide file tree
Showing 17 changed files with 52 additions and 52 deletions.
6 changes: 3 additions & 3 deletions R/appenders.R
Original file line number Diff line number Diff line change
Expand Up @@ -212,8 +212,8 @@ appender_slack <- function(channel = Sys.getenv("SLACK_CHANNEL"),


#' Send log messages to Pushbullet
#' @param ... parameters passed to `pbPost`, such as `recipients` or
#' `apikey`, although it's probably much better to set all these
#' @param ... parameters passed to [RPushbullet::pbPost], such as `recipients`
#' or `apikey`, although it's probably much better to set all these
#' in the `~/.rpushbullet.json` as per package docs at
#' <http://dirk.eddelbuettel.com/code/rpushbullet.html>
#' @export
Expand Down Expand Up @@ -391,7 +391,7 @@ appender_async <- function(appender,

# Start one background process (hence dispatcher not required)
# force = FALSE allows multiple appenders to use same namespace logger
mirai::daemons(1L, dispatcher = "none", force = FALSE, .compute = namespace)
mirai::daemons(1L, dispatcher = FALSE, force = FALSE, cleanup = FALSE, .compute = namespace)
mirai::everywhere(
{
library(logger)
Expand Down
28 changes: 14 additions & 14 deletions R/formatters.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ formatter_paste <- function(...,
}
attr(formatter_paste, "generator") <- quote(formatter_paste())

#' Apply `sprintf` to convert R objects into a character vector
#' @param fmt passed to `sprintf`
#' @param ... passed to `sprintf`
#' Apply [sprintf()] to convert R objects into a character vector
#' @param fmt passed to [sprintf()]
#' @param ... passed to [sprintf()]
#' @inheritParams log_level
#' @return character vector
#' @export
Expand All @@ -28,8 +28,8 @@ formatter_sprintf <- function(fmt,
}
attr(formatter_sprintf, "generator") <- quote(formatter_sprintf())

#' Apply `glue` to convert R objects into a character vector
#' @param ... passed to `glue` for the text interpolation
#' Apply [glue::glue()] to convert R objects into a character vector
#' @param ... passed to [glue::glue()] for the text interpolation
#' @inheritParams log_level
#' @return character vector
#' @export
Expand Down Expand Up @@ -63,8 +63,8 @@ formatter_glue <- function(...,
attr(formatter_glue, "generator") <- quote(formatter_glue())


#' Apply `glue_safe` to convert R objects into a character vector
#' @param ... passed to `glue_safe` for the text interpolation
#' Apply [glue::glue_safe()] to convert R objects into a character vector
#' @param ... passed to [glue::glue_safe()] for the text interpolation
#' @inheritParams log_level
#' @return character vector
#' @export
Expand Down Expand Up @@ -94,18 +94,18 @@ formatter_glue_safe <- function(...,
attr(formatter_glue_safe, "generator") <- quote(formatter_glue_safe())


#' Apply `glue` and `sprintf`
#' Apply [glue::glue()] and [sprintf()]
#'
#' The best of both words: using both formatter functions in your log
#' messages, which can be useful eg if you are migrating from
#' `sprintf` formatted log messages to `glue` or similar.
#' [sprintf()] formatted log messages to [glue::glue()] or similar.
#'
#' Note that this function tries to be smart when passing arguments to
#' `glue` and `sprintf`, but might fail with some edge cases, and
#' [glue::glue()] and [sprintf()], but might fail with some edge cases, and
#' returns an unformatted string.
#' @param msg passed to `sprintf` as `fmt` or handled as part of `...`
#' in `glue`
#' @param ... passed to `glue` for the text interpolation
#' @param msg passed to [sprintf()] as `fmt` or handled as part of `...`
#' in [glue::glue()]
#' @param ... passed to [glue::glue()] for the text interpolation
#' @inheritParams log_level
#' @return character vector
#' @family log_formatters
Expand Down Expand Up @@ -229,7 +229,7 @@ skip_formatter <- function(message, ...) {
#' is a string, then [sprintf()] is being called -- otherwise it does
#' something like [log_eval()] and logs the R expression(s) and the
#' result(s) as well.
#' @param ... string and further params passed to `sprintf` or R
#' @param ... string and further params passed to [sprintf()] or R
#' expressions to be evaluated
#' @inheritParams log_level
#' @return character vector
Expand Down
2 changes: 1 addition & 1 deletion R/helpers.R
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ log_with_separator <- function(...,


#' Tic-toc logging
#' @param ... passed to `log_level`
#' @param ... passed to [log_level()]
#' @param level see [log_levels()]
#' @param namespace x
#' @export
Expand Down
6 changes: 3 additions & 3 deletions R/hooks.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#' Injects a logger call to standard messages
#'
#' This function uses `trace` to add a `log_info` function call when
#' This function uses [trace()] to add a [log_info()] function call when
#' `message` is called to log the informative messages with the
#' `logger` layout and appender.
#' @export
Expand Down Expand Up @@ -61,8 +61,8 @@ log_warnings <- function(muffle = getOption("logger_muffle_warnings", FALSE)) {

#' Injects a logger call to standard errors
#'
#' This function uses `trace` to add a `log_error` function call when
#' `stop` is called to log the error messages with the `logger` layout
#' This function uses [trace()] to add a [log_error()] function call when
#' [stop()] is called to log the error messages with the `logger` layout
#' and appender.
#' @param muffle if TRUE, the error is not thrown after being logged
#' @export
Expand Down
8 changes: 4 additions & 4 deletions R/layouts.R
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,10 @@ get_logger_meta_variables <- function(log_level = NULL,

#' Generate log layout function using common variables available via glue syntax
#'
#' `format` is passed to `glue` with access to the below variables:
#' `format` is passed to [glue::glue()] with access to the below variables:
#' \itemize{ \item msg: the actual log message \item further variables
#' set by [get_logger_meta_variables()] }
#' @param format `glue`-flavored layout of the message using the above
#' @param format [glue::glue()]-flavored layout of the message using the above
#' variables
#' @return function taking `level` and `msg` arguments - keeping the
#' original call creating the generator in the `generator` attribute
Expand Down Expand Up @@ -193,7 +193,7 @@ layout_logging <- function(level,
}
attr(layout_logging, "generator") <- quote(layout_logging())

#' Format a log message with `glue`
#' Format a log message with [glue::glue()]
#'
#' By default, this layout includes the log level of the log record as
#' per [log_levels()], the current timestamp and the actual log
Expand All @@ -207,7 +207,7 @@ attr(layout_logging, "generator") <- quote(layout_logging())
layout_glue <- layout_glue_generator()
attr(layout_glue, "generator") <- quote(layout_glue())

#' Format a log message with `glue` and ANSI escape codes to add colors
#' Format a log message with [glue::glue()] and ANSI escape codes to add colors
#'
#' Colour log levels based on their severity. Log levels are coloured
#' with [colorize_by_log_level()] and the messages are coloured with
Expand Down
4 changes: 2 additions & 2 deletions man/appender_pushbullet.Rd

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

6 changes: 3 additions & 3 deletions man/formatter_glue.Rd

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

12 changes: 6 additions & 6 deletions man/formatter_glue_or_sprintf.Rd

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

6 changes: 3 additions & 3 deletions man/formatter_glue_safe.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/formatter_logging.Rd

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

8 changes: 4 additions & 4 deletions man/formatter_sprintf.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/layout_glue.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/layout_glue_colors.Rd

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

4 changes: 2 additions & 2 deletions man/layout_glue_generator.Rd

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

4 changes: 2 additions & 2 deletions man/log_errors.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/log_messages.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/log_tictoc.Rd

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

0 comments on commit 2b2cf94

Please sign in to comment.