Sentinel
Debugging
As policies become more complex, it becomes harder to understand exactly why a policy may be behaving differently than you expect.
Prior to actively debugging, there are multiple best practices we recommend following. We recommend breaking your policy down into a set of rules. This will make it easier to understand traces and make it easier to test your policies. This should help to debug policies up to a significant complexity.
Print Logging
The built-in print function can be used to log data. The print output is only shown during failures or when tracing is explicitly enabled.
The print
function outputs each argument, which can be of any type, converted
to a human-friendly string format. Arguments are separated with a single space.
Example:
Sentinel Playground
Loading the playground...
Press "Run" to get policy output
The print
function returns the value true
so that it can also be
used within rule expressions. Note that the print
function should be
used at the beginning of statements otherwise they may never be
reached. This is due to internal performance techniques within Sentinel
like short-circuiting.
Example:
Sentinel Playground
Loading the playground...
Press "Run" to get policy output