gather_messages: Gather error and warning messages from the Rout-file

View source: R/gather_messages.R

gather_messagesR Documentation

Gather error and warning messages from the Rout-file

Description

Reads the Rout-file generated when running R in batch mode. Identifies lines with error and warning messages and report these. It is possible to predefine allowed warnings that shall not be reported.

Usage

gather_messages(
  filename,
  remove_allowed = c("was built under R version"),
  remove_after = "Ferdig Batch"
)

Arguments

filename

[character(1)]
The name of the Rout-file.

remove_allowed

[character]
Warning text that is allowed, case is ignored. Defaults to c("was built under R version").

remove_after

[character]
Removes all messages after a predefined tag, case is ignored. See details. Defaults to "Ferdig Batch".

Details

remove_allowed is used to remove warnings that is allowed. Warnings that include the specified text string(s) will be removed. As default warnings including the string "was built under R version" will be removed. These warnings indicate that the package was built for a later R-version than the version used to run the R-script. remove_after is used to remove all messages after a predefined tag. The tag can be set using print() in the R-script producing the Rout-file. This may be useful as error messages will be produced at the end of Rout-file if the user don't have writing access at working directory from which R-script is run.

Value

Vector with error and warning messages that was written in the log.

Author(s)

Petter Hopp Petter.Hopp@vetinst.no

Examples

## Not run: 
# Gather messages from the log file "script.Rout".
library(NVIbatch)
messages <- gather_messages(filename = file.path(getwd(), "script.Rout"),
                              remove_after = "Finished script")

## End(Not run)

NorwegianVeterinaryInstitute/NVIbatch documentation built on Dec. 15, 2024, 3:15 p.m.