How can I see logs from a custom UI resolver

Hello,

I am experimenting with the Forge environment. I have a resolver like this one:


const resolver = new Resolver();

resolver.define('getText', (req) => {
    console.log(req);

    var bodyData = `{
        "editPermissions": [],
        "name": "Auditors dashboard",
        "description": "A dashboard to help auditors identify sample of issues to check.",
        "sharePermissions": [
          {
            "type": "global"
          }
        ]
      }`;
      
      const response = api.asApp().requestJira(route`/rest/api/3/dashboard`, {
        method: 'POST',
        headers: {
          'Accept': 'application/json',
          'Content-Type': 'application/json'
        },
        body: bodyData
      }).then(() => {
        console.log(`Response: ${response.status} ${response.statusText}`);
        return response.json();
      }).then((response) => {
        console.log(response);
      }) ;

    return 'Hello, world!';
});

And I invoke it like this from the React code:

    invoke("getText").then((returnedData) => {
      console.log(returnedData);
    });

My question is where can I see the logs from the custom UI resolver. I’ve tried to use the forge tunnel and forge logs but I can’t see my console.logs there. The logs from the React code I can see them in Developer Console.

1 Like

Hey @bogdan

Firstly, in your code, the then-callback is executed in the browser. Therefore, you should be able to see the log in the browser dev console.

However, if you want to see these logs in production for every invocation for every user, you will need to create a feature request in our FRGE board as this functionality is not ready yet.

The “then” from the invoke is indeed executed in the browser so I can see the console.log(returnedData); log.

However, I am interested to see the logs from the resolver.defined callback. For example, this one:

resolver.define('getText', (req) => {
    console.log(req);
    ...
});

I want to see these logs during development stage so that I can debug the code there.

These logs should definitely be available during forge tunnel. There are two reasons why you don’t see them:

  1. You should be logged in under the same account in your browser as your Forge CLI. Make sure you’re logged in.
  2. Maybe req is too complicated (circular references etc) so console.log can’t log it. Try logging something simple like a string.
1 Like