sinkall: Divert stdout and stderr to a File

Description Usage Arguments Value Examples

View source: R/sinkall.R

Description

This is a simple utility function to direct the output of stdout and stderr to a file. stdout is the information normally printed in the console, for instance the results of print(rnorm(5)). stderr is the output created by functions message, warning and stop. The purpose of this function is to allow one to direct all this output into a single file where the results can be studied, for instance, for troubleshooting purposes. Works exactly like the base sink() function: you have to call it a second time with no arguments to close the file.

Usage

1
sinkall(filename = NULL)

Arguments

filename

Character. A path to a filename where the results will be captured.

Value

NULL, invisibly.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
## Not run: 
tf <- tempfile(pattern = "SinkDemo", fileext = "txt")
sinkall(tf)
print("Hello")
print(rnorm(2))
print(normr(2)) # typo, so it errors
message("A message from message()")
warning("A warning from warning()")
cat("Information via cat\\n")
sinkall() # one must close the file connection
file.show(tf)

## End(Not run)

bryanhanson/readJDX documentation built on July 25, 2020, 9:24 p.m.