This function logs the parameters and the call time of a specified function to a log file. If any of the parameters are matrices or vectors longer than 5 elements, their values will not be printed in the log.
log_parameters(func, logfile, ...)
The result of the function func
.
my_function <- function(a, b, c = 10) {
return(a + b + c)
}
result <- log_parameters(my_function, "my_log", a = 1, b = 2, c = 3)
#> [1] "2025-07-26 11:03:43 EDT"
#> [1] "my_function"
#> [1] "logging ... 3"
#> [1] "[2025-07-26 11:03:43.876604] my_function called with: a = 1, type = numeric, b = 2, type = numeric, c = 3, type = numeric\n"
print(result)
#> [1] 6