How to print the value of input data when using shopify functions?

I am working on payment customization functions.

I want to see the input being for the payment Methods so that I could use logics to implement my function.

query RunInput {
  paymentMethods {
    id
    name
  }
}

How do check these print logs for my dev store that is in live production ?

There are no equivalent GraphQL admin/storefront APIs that might help me with this data.

I followed these docs:

Hi @hsharda

You cannot print logs or view console/debug output from Shopify Functions in production or on your live store. Shopify Functions (including payment customization functions) run in a secure, isolated environment where:

  • There is no access to stdout, stderr, or any logging mechanism.
  • You cannot use console.log, print!, or similar statements to output logs.
  • There is no way to view “print logs” from a live or production store.

How to debug your function:

  • Use local testing with the Shopify CLI (shopify app function run) to see output and errors.
  • Write unit tests for your function logic (see examples in the files you uploaded).
  • Use the Shopify CLI’s preview and test commands to simulate input and see the output.
  • If you need to inspect what input your function receives, add test cases with sample input JSON.

We have docs on testing and debugging Functions here: Test and debug Shopify Functions

Just wanted to add a note here for anyone reading this in future.

Anything you write to STDERR, is printed to LOGS, and viewable in your partner portal:

A few caveats, as per @Liam-Shopify’s initial reply:

1.) Production function runs must be shared by a brand, before you can view run details (including logs).
2.) The message is truncated (I forget the exact size).
3.) This WILL have a negative impact on ‘instruction count’, so you should be careful when logging in production.

A better approach to debugging, would be:

1.) Have the brand share their function logs.
2.) Copy the input, and run the function locally against that input (with Shopify CLI)
3.) Add any debuggers, console.errors etc that you need