Skip to contents

AppenderRedis writes log messages to a Redis data base. This lgr::Appender is created internally by RushWorker when logger thresholds are passed via rush_plan().

Value

Object of class R6::R6Class and AppenderRedis with methods for writing log events to Redis data bases.

Super classes

lgr::Filterable -> lgr::Appender -> lgr::AppenderMemory -> AppenderRedis

Methods

Inherited methods


Method new()

Creates a new instance of this R6 class.

Usage

AppenderRedis$new(
  config,
  key,
  threshold = NA_integer_,
  layout = lgr::LayoutJson$new(),
  buffer_size = 0,
  flush_threshold = "error",
  flush_on_exit = TRUE,
  flush_on_rotate = TRUE,
  should_flush = NULL,
  filters = NULL
)

Arguments

config

(redux::redis_config)
Redis configuration options.

key

(character(1))
Key of the list holding the log messages in the Redis data store.

threshold

(integer(1) | character(1))
Threshold for the log messages.

layout

(lgr::Layout)
Layout for the log messages.

buffer_size

(integer(1))
Size of the buffer.

flush_threshold

(character(1))
Threshold for flushing the buffer.

flush_on_exit

(logical(1))
Flush the buffer on exit.

flush_on_rotate

(logical(1))
Flush the buffer on rotate.

should_flush

(function)
Function that determines if the buffer should be flushed.

filters

(list)
List of filters.


Method flush()

Sends the buffer's contents to the Redis data store, and then clears the buffer.

Usage

AppenderRedis$flush()

Examples

# This example is not executed since Redis must be installed
# \donttest{
   config_local = redux::redis_config()

   rush_plan(
     config = config_local,
     n_workers = 2,
     lgr_thresholds = c(rush = "info"))
#> Error in rush_plan(config = config_local, n_workers = 2, lgr_thresholds = c(rush = "info")): Can't connect to Redis. Check the configuration.

   rush = rsh(network_id = "test_network")
#> Error in initialize(...): Can't connect to Redis. Check the configuration.
   rush
#> Error in eval(expr, envir, enclos): object 'rush' not found
# }