Debugging
Debugging is an important part of developing flows. This section will explain about debugging in general and how to debug flows and code in flows.
Understand the Problem
Before you start debugging, it's crucial to understand the problem thoroughly. Reproduce the issue consistently and gather information about the symptoms, error messages, and the context in which the problem occurs. Understanding the problem helps you narrow down the potential causes.
Break the Problem Down
Complex issues are often easier to debug when broken down into smaller, manageable parts. Isolate the problematic code or component, and focus your debugging efforts on that specific area. One way of doing this is by limiting the data that goes into the flow. For example, if you are debugging a flow that retrieves data from the Content Store, you can use a filter to limit the number and type of objects that are retrieved.
Use Debugging Tools
Xill4 provides powerful debugging tools to help inspect and trace messages throughout a flow:
-
Debug Components
-
Logger
TheLoggercomponent logs the incoming message together with a configurable custom message, making it easier to trace flow behavior without modifying code. -
Print
ThePrintcomponent prints the incoming message as received by the component. When using the Print component, the actual incoming message is shown without this additional metadatavalueadded to the object. This resembles the actual object that is used asvaluein a code component. -
Counter
TheCountercomponent prints the count of incoming messages.
-
-
log()method in custom code segments
This function can be used inside a Code component to write custom log messages during execution, which is useful for debugging code and inspecting values. Click here for more information about the log function. -
Debug Mode
TheDebug mode, which can be enabled through the context menu on each component, allows you to follow messages and see how they transform as they travel through the flow by automatically logging all incoming and outgoing messages for that component.
Except for the Print and Counter components, all previous options create logs within the database set by the variable XILL4_DATABASE_CONNECTION_STRING using the logs collection.
Keep in mind that logs shown in the Console panel of a flow, including logs created through Debug mode, the Logger component, or the log() function, contain additional metadata in the form of a value field, which is added at the top level of the logged object.
This corresponds when using a Code component, as there the incoming object is accessed using value. But this value field is not part of the actual incoming message.
Test in Isolation
When debugging, focus on isolating the problem by testing individual components or functions separately. This helps you pinpoint the source of the issue more efficiently.
Be Systematic
Systematically test hypotheses about the root cause of the issue. Start with the most likely scenarios, gather evidence, and eliminate possibilities one by one.
Test Fixes Thoroughly
After identifying a potential fix, test it rigorously to ensure that it resolves the issue without introducing new problems
Review Recent Changes
If the issue surfaced after making recent code changes, review those changes carefully. Sometimes, a small code modification can introduce unexpected problems.
Testing on the Content Store
When testing involves making changes to the Content Store, make a backup of the Content Store before making any changes. This allows you to easily revert to the previous state if necessary. Do this continuously for the various stages of the migration or a flow you are testing.