Workflow

Debugging

Debugging a workflow is best done with Alfred's Workflow Debugger. You can tell when the Debugger is active using the alfred debugging method:

if ($workflow->alfred()->debugging()) {
    // Debugger is open and active!
}

If you want to log information to the Workflow Debugger, you can use the logger method. This method will only print logs when the Workflow Debugger is open:

$workflow->logger()->info('HOME: ' . $workflow->env('HOME'));
// Anything JSON-encodable will be JSON encoded
$workflow->logger()->info(['Tina', 'Gene', 'Louise']);

In the Workflow Debugger, this will show up as:

[example-workflow] 2022-08-10 16:51:04 HOME: /Users/me
[example-workflow] 2022-08-10 16:51:04 ["Tina","Gene","Louise"]

By default, logs are prefixed with [your workflow name], but you can set your own prefix:

$workflow->logger()->setPrefix('heads-up');
$workflow->logger()->info('HOME: ' . $workflow->env('HOME'));
// [heads-up] 2022-08-10 16:51:04 HOME: /Users/me
Previous
Outputting