Debugging your apps in Appsmith with the Appsmith Debugger, part 2
Meet the sidekicks, Logs and Inspect Entity
The first part of this teardown helped you see how the Error pane can save you hours in debugging and build better internal apps. In this one, let’s meet two seemingly innocuous features that can give you debugging super-powers when used right.
The Logs pane shows you everything logged by Appsmith and, like Errors, in lockstep with the sequence of code execution in your build. Borrowing from the experience of showing logs in general—in the browser console, from a shell, or on your favorite IDE—the Logs pane has four views for specific debugging use cases.
This view shows you all logs timestamped by when we saw them in your Appsmith session. Updated a widget’s property? Wrote a new action to your GraphQL datasource? Ran a JS Object to concat two queries? It all gets logged, including the errors you see in the Errors pane, in a separate view called Error Logs. You will see how that can be useful in a GIF, pun intended.
The All Logs view can be a little overwhelming, though, and a bit of work when you have been at your build for a while. For easier tracking of relevant logs, use one of the three options below.
Everything you learned about the Errors pane applies to this view, too, but there’s more to this view. Here's a likely scenario to show that.
You have a button to reload a table, presumably to refresh the data from your datasource.
You use the Button property, onClick, which runs the query to fetch the latest data into the table.
Your query fails.
- On just the Error pane
- You see just the error for the failing query. Although helpful, it doesn’t offer context for the before and after of the error.
- On the Error Logs pane under Logs
- You see logs for the Button click and the executed onClick event .
- Because the onClick property is binded to queries and JS Objects, you see the ones that are successfully executed and those that fail.
The triaging in our example above is especially useful when you have nested queries, several dependent bindings, and a more complex workflow overall.
Set points in your code that you want to log statements at, view tabular data, or see groups for repeated errors.
Automatically tracking all your interactions with Appsmith during build, System Logs show a helpful trail of activity by descending order of timestamp, especially useful when you want to go back in time or pivot from a point of failure to everything that led to it.
They show up for different situations and interactions for the type of entity you are working with.
With widgets, you see a log when you
- Drag-and-drop a new widget on the canvas.
- Update the widget’s properties
Updating a property also updates all its dependent properties which then show up in System Logs.
- Trigger events with an end-user action.
- Delete a widget from the canvas
With actions, you see them when you
- Create a new datasource or a query
- Update query properties like queryName, queryBody, queryConfiguration, and queryProperties.
- Execute a query
- Delete a query
With JS Objects, you’ll see system logs when you
- Create and update code inside JS Objects
- Execute JS Objects
Just like errors, system logs are native to entities and have four parts to them.
Logged as your entities are created, updated and deleted, these little breadcrumbs help you track back from when the error occurred to when it was last A-Okay.
Useful during build, the message of the log answers two questions— what were you doing with an entity—creating it, updating it, deleting it—and what happened with your action—success or failure.
- With widgets, outside of CRUD information, you also see event-specific info like onClick and showAlert linked to those widgets.
- Queries and JS Objects are straightforward with start and end points that indicate if they were updated, ran, and failed.
Like errors, a system log has two parts to its source—the entity’s name.the type of entity, e.g., SELECT1.TABLE1.WIDGET.
👌🏽 Appsmith Experience plug
Clicking the source from the logs takes you to the associated entity anywhere in Appsmith, be it a widget, a query, or a JS Object. Noice!
This doesn’t always show, but when it does, it can be useful confirmation of a binding working, a query running successfully, or a JS Object executing completely.
- For widgets, you see which properties are updated when you are configuring them and how.
Say you’re updating the text widget’s background property and you don’t see it change on the canvas. Track the log to the response for a quick confirmation of that and troubleshoot the canvas next.
- For queries, you’ll see two different logs—the start of a query run and the status of its execution.
The first type of log will show you configuration details of the query—helpful to verify if the config matches the request.
- The second type will throw an error if the run fails. When the query runs successfully, it shows all the parameters that the query ran with and the time taken for the response.
- With JS Objects, you see the response from the function as a JSON after an object is successfully run. This shows you how Appsmith handles the function while evaluating and running it and can be useful for spotting conflicts, undefined references, or troublesome variables.
Borrowing from a modern browser’s Inspect Element feature, Inspect Entity lets you see incoming and outgoing entities for any widget. These entities can be queries, JS Objects, or even other widgets.
- Incoming entities are those that fetch data from the datasource into the widget.
For example, if the data on a table is populated by a Postgres query, you’ll see the query name under the Incoming entities column.
- Outgoing entities are those that can specify the data that’s to be sent to the datasource in a typical CUD operation and then send it to your datasource.
Say, a text widget is binded to a table's selectedRow property, you will see the text widget’s name under the Outgoing entities column.
The Inspect Entity pane lets you see dependencies for all your widgets on the canvas, especially useful if you have a medium-complex app with several widgets working off of each other. For example, when you have a parent widget or query that controls bindings on other dependent widgets---call them children widgets---, Inspect Entity can show you all those children when you click the parent and quickly take you to any one of them directly.
In combination with Errors, Logs and Inspect Entity round out the Debugger for several scenarios during build and save you hours in building an app end-users love. Try out the Debugger and let us know how you like it, what it's missing, and what we can improve. Our Discord is the best place for that feedback.