f <- function(){
cat("stdout message\n")
message("stderr message")
warning("stderr warning", immediate. = TRUE)
}
# example of generated wrapper
g <- .silenceF(f)
g
# use of silencing level
for(l in 7:-7){ message("\nLevel: ", l); .silenceF(f, l)() }
# inline functions
ifun <- .silenceF(function(){ f(); invisible(1) })
ifun()
ifun <- .silenceF(function(){ f(); 1 })
ifun()
ifun <- .silenceF(function(){ f(); 1 }, 2L)
ifun()
Run the code above in your browser using DataLab