Skip to content

Commit

Permalink
Merge pull request daroczig#160 from hadley/rdname
Browse files Browse the repository at this point in the history
Use `@rdname`
  • Loading branch information
daroczig authored Jul 31, 2024
2 parents 1878fd0 + d5b8bb9 commit 088b679
Show file tree
Hide file tree
Showing 6 changed files with 101 additions and 84 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Date: 2024-03-03
URL: https://daroczig.github.io/logger/
BugReports: https://github.com/daroczig/logger/issues
Encoding: UTF-8
RoxygenNote: 7.3.1
RoxygenNote: 7.3.2
License: AGPL-3
Imports:
utils
Expand Down
6 changes: 1 addition & 5 deletions R/appenders.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,14 @@ appender_void <- structure(function(lines) {}, generator = quote(appender_void()
#' Append log record to stderr
#' @param lines character vector
#' @export
#' @aliases appender_stderr
#' @usage
#' appender_console(lines)
#'
#' appender_stderr(lines)
#' @seealso This is a \code{\link{log_appender}}, for alternatives, see eg \code{\link{appender_stdout}}, \code{\link{appender_file}}, \code{\link{appender_tee}}, \code{\link{appender_slack}}, \code{\link{appender_pushbullet}}, \code{\link{appender_telegram}}, \code{\link{appender_syslog}}, \code{\link{appender_kinesis}} and \code{\link{appender_async}} for evaluate any \code{\link{log_appender}} function in a background process.
appender_console <- structure(function(lines) {
cat(lines, file = stderr(), sep = '\n')
}, generator = quote(appender_console()))


#' @export
#' @rdname appender_console
appender_stderr <- appender_console


Expand Down
35 changes: 18 additions & 17 deletions R/levels.R
Original file line number Diff line number Diff line change
Expand Up @@ -16,39 +16,40 @@ log_levels_supported <- c('OFF', 'FATAL', 'ERROR', 'WARN', 'SUCCESS', 'INFO', 'D
#' \item \code{TRACE} A fine-grained debug message, typically capturing the flow through the application.
#' }
#' @references \url{https://logging.apache.org/log4j/2.x/javadoc/log4j-api/org/apache/logging/log4j/Level.html}, \url{https://logging.apache.org/log4j/2.x/manual/customloglevels.html}
#' @aliases log_levels OFF FATAL ERROR WARN SUCCESS INFO DEBUG TRACE
#' @name log_levels
NULL

#' @rdname log_levels
#' @usage
#' TRACE
#'
#' DEBUG
#'
#' INFO
#'
#' SUCCESS
#'
#' WARN
#'
#' ERROR
#'
#' FATAL
#'
#' OFF
#' @export
#' @format NULL
OFF <- structure(0L, level = 'OFF', class = c('loglevel', 'integer'))
#' @export
#' @rdname log_levels
#' @format NULL
FATAL <- structure(100L, level = 'FATAL', class = c('loglevel', 'integer'))
#' @export
#' @rdname log_levels
#' @format NULL
ERROR <- structure(200L, level = 'ERROR', class = c('loglevel', 'integer'))
#' @export
#' @rdname log_levels
#' @format NULL
WARN <- structure(300L, level = 'WARN', class = c('loglevel', 'integer'))
#' @export
#' @rdname log_levels
#' @format NULL
SUCCESS <- structure(350L, level = 'SUCCESS', class = c('loglevel', 'integer'))
#' @export
#' @rdname log_levels
#' @format NULL
INFO <- structure(400L, level = 'INFO', class = c('loglevel', 'integer'))
#' @export
#' @rdname log_levels
#' @format NULL
DEBUG <- structure(500L, level = 'DEBUG', class = c('loglevel', 'integer'))
#' @export
#' @rdname log_levels
#' @format NULL
TRACE <- structure(600L, level = 'TRACE', class = c('loglevel', 'integer'))

#' @export
Expand Down
32 changes: 7 additions & 25 deletions R/logger.R
Original file line number Diff line number Diff line change
Expand Up @@ -247,31 +247,6 @@ log_namespaces <- function() {
#' @param .topenv original frame of the \code{.topcall} calling function where the formatter function will be evaluated and that is used to look up the \code{namespace} as well via \code{logger:::top_env_name}
#' @seealso \code{\link{logger}}
#' @export
#' @aliases log_level log_fatal log_error log_warn log_success log_info log_debug log_trace
#' @usage
#' log_level(level, ..., namespace = NA_character_,
#' .logcall = sys.call(), .topcall = sys.call(-1), .topenv = parent.frame())
#'
#' log_trace(..., namespace = NA_character_,
#' .logcall = sys.call(), .topcall = sys.call(-1), .topenv = parent.frame())
#'
#' log_debug(..., namespace = NA_character_,
#' .logcall = sys.call(), .topcall = sys.call(-1), .topenv = parent.frame())
#'
#' log_info(..., namespace = NA_character_,
#' .logcall = sys.call(), .topcall = sys.call(-1), .topenv = parent.frame())
#'
#' log_success(..., namespace = NA_character_,
#' .logcall = sys.call(), .topcall = sys.call(-1), .topenv = parent.frame())
#'
#' log_warn(..., namespace = NA_character_,
#' .logcall = sys.call(), .topcall = sys.call(-1), .topenv = parent.frame())
#'
#' log_error(..., namespace = NA_character_,
#' .logcall = sys.call(), .topcall = sys.call(-1), .topenv = parent.frame())
#'
#' log_fatal(..., namespace = NA_character_,
#' .logcall = sys.call(), .topcall = sys.call(-1), .topenv = parent.frame())
#' @examples \dontrun{
#' log_level(INFO, 'hi there')
#' log_info('hi there')
Expand Down Expand Up @@ -352,36 +327,43 @@ validate_log_level <- function(level) {


#' @export
#' @rdname log_level
log_fatal <- function(..., namespace = NA_character_,
.logcall = sys.call(), .topcall = sys.call(-1), .topenv = parent.frame()) {
log_level(FATAL, ..., namespace = namespace, .logcall = .logcall, .topcall = .topcall, .topenv = .topenv)
}
#' @export
#' @rdname log_level
log_error <- function(..., namespace = NA_character_,
.logcall = sys.call(), .topcall = sys.call(-1), .topenv = parent.frame()) {
log_level(ERROR, ..., namespace = namespace, .logcall = .logcall, .topcall = .topcall, .topenv = .topenv)
}
#' @export
#' @rdname log_level
log_warn <- function(..., namespace = NA_character_,
.logcall = sys.call(), .topcall = sys.call(-1), .topenv = parent.frame()) {
log_level(WARN, ..., namespace = namespace, .logcall = .logcall, .topcall = .topcall, .topenv = .topenv)
}
#' @export
#' @rdname log_level
log_success <- function(..., namespace = NA_character_,
.logcall = sys.call(), .topcall = sys.call(-1), .topenv = parent.frame()) {
log_level(SUCCESS, ..., namespace = namespace, .logcall = .logcall, .topcall = .topcall, .topenv = .topenv)
}
#' @export
#' @rdname log_level
log_info <- function(..., namespace = NA_character_,
.logcall = sys.call(), .topcall = sys.call(-1), .topenv = parent.frame()) {
log_level(INFO, ..., namespace = namespace, .logcall = .logcall, .topcall = .topcall, .topenv = .topenv)
}
#' @export
#' @rdname log_level
log_debug <- function(..., namespace = NA_character_,
.logcall = sys.call(), .topcall = sys.call(-1), .topenv = parent.frame()) {
log_level(DEBUG, ..., namespace = namespace, .logcall = .logcall, .topcall = .topcall, .topenv = .topenv)
}
#' @export
#' @rdname log_level
log_trace <- function(..., namespace = NA_character_,
.logcall = sys.call(), .topcall = sys.call(-1), .topenv = parent.frame()) {
log_level(TRACE, ..., namespace = namespace, .logcall = .logcall, .topcall = .topcall, .topenv = .topenv)
Expand Down
87 changes: 64 additions & 23 deletions man/log_level.Rd

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

23 changes: 10 additions & 13 deletions man/log_levels.Rd

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

0 comments on commit 088b679

Please sign in to comment.