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, ...)

Arguments

func

The function to be called and logged.

logfile

The name of the log file where the function call information will be saved. The actual file will be named logfile_function_calls.log.

...

Additional arguments to be passed to the function func.

Value

The result of the function func.

Examples

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