Logging and debugging in FaaSr

Overview

When FaaSr functions execute in the cloud, errors may happen, and it is important that you add logging information so you can debug these errors. Because FaaS functions are stateless, FaaSr also use cloud S3 bucket storage to persist logging information.

Configuring logging folder in S3

By default, logs are stored in a folder named FaaSrLog in your configured S3 bucket. You can specify a different folder name in your JSON configuration file using the FaaSr JSON Builder, under the General configuration pull-down. Within this folder, for every execution of a workflow, a randomly-generated UUID (a long name that looks like 2f66208d-63eb-4fd9-b54b-7bebcc970421) is created to store the logs for that workflow. The reason a UUID folder is created is to ensure that every FaaSr workflow execution has its own separate logs. In this way, you are able to safely run multiple workflows concurrently, and their logs are separate

Logging from your code

To add a message to the log, use the faasr_log() function, with the following pattern as an example:

log_msg <- paste0('Function compute_sum finished; output written to ', folder, '/', output, ' in default S3 bucket')
faasr_log(log_msg)

Accessing logs

Logs are stored in S3. You may use any S3-compatible client to browse the logs, or use FaaSr functions to help you list and download them.

For example, using minioclient:

mc_ls("play/faasr/FaaSrLog/")

We’ll assume UUID 2f66208d-63eb-4fd9-b54b-7bebcc970421 in the examples below; please replace appropriately:

mc_ls("play/faasr/FaaSrLog/2f66208d-63eb-4fd9-b54b-7bebcc970421/")

Each action’s log is written as a file with the action’s name and extension .txt. For example, the log for Action1 would be:

mc_cat("play/faasr/FaaSrLog/2f66208d-63eb-4fd9-b54b-7bebcc970421/Action1.txt")

While minioclient helps you browse the log files server, FaaSr provides these following helper functions

$get_log_df

Queries for all logs in your S3 bucket and writes a data frame with this information to file named faasr_output_logs.txt in your current working directory.

$get_log("2f66208d-63eb-4fd9-b54b-7bebcc970421")

Downloads the logs from the S3 bucket for a particular UUID (which you can determine by inspecting faasr_output_logs.txt)

$delete_log("2f66208d-63eb-4fd9-b54b-7bebcc970421")

Deletes a specific log from the S3 bucket given its UUID

$delete_log_date("2024-06-11")

Deletes all logs older than (and including) the given date

Locating specific UUID

To find out the specific UUID for a workflow run, you can check the FaaS-specific platform logs.

GitHub Actions

You can go to the FaaSr-created Action repo, and click on the Actions tab, and expand the run Rscript link to see the Action Invocation ID, which matches the UUID for your logs:

Locating UUID for logs, in GitHub Actions
Locating UUID for logs, in GitHub Actions