Watch for a log of something.

logwatch(
  what,
  get_status,
  get_log,
  show_log = TRUE,
  skip = 0,
  show_spinner = TRUE,
  poll = 1,
  timeout = Inf,
  status_waiting = "waiting",
  status_running = "running",
  status_timeout = "timeout",
  status_interrupt = "interrupt",
  multiple = FALSE
)

Arguments

what

Very short summary of the process underlying the logs. Examples include "task", "installation", etc.

get_status

Function that will fetch a status. Accepts no arguments, and returns one of a set of (by default) "waiting", "running" or any status you like after that. When status is "waiting" we show a spinner but do not stream logs. When "running" we stream logs (but don't show a spinner). Any other statement returns. You can change the expected "waiting" or "running" status values with the status_waiting and status_running arguments.

get_log

A callback to read logs of the installation (something like function() readLines(filename, warn = FALSE) may be sufficient), or NULL if log fetching is not possible.

show_log

Logical, indicating if the installation log should be printed.

skip

Optional integer indicating how to handle log content that exists at the point where we start watching. The default (0) shows all log contents. A positive integer skips that many lines, while a negative integer shows only that many lines (so -5 shows the first five lines in the log). You can pass Inf to discard all previous logs, but stream all new ones.

show_spinner

Logical, indicating if a spinner should be shown while waiting for the task to start, and if show_log is FALSE for the task to complete.

poll

Time, in seconds, used to throttle calls to the status function. The default is 1 second

timeout

Timeout, in seconds, after which we give up. This does not cancel the underlying process being watched! We return status_timeout after a timeout (by default "timeout").

status_waiting

The value of a waiting status (can be a vector of possible statuses)

status_running

The value of a running status (can be a vector of possible statuses)

status_timeout

The value to return if we timeout

status_interrupt

The value to return if we are interrupted

multiple

Logical, indicating if get_status() is expected to return multiple values. This changes the progress printing slightly by disabling the logging (even if get_log is provided and show_log = TRUE, logs are never fetched or shown), and there is no longer a distinction between waiting for things to start vs complete. Instead, we print a summary of things in the waiting, running and finished states.

Value

A list with elements:

  • status: Your final status call

  • start: The start time

  • end: The end time