1. Download the bundlet, and place it in your workflow's root directory.
2. Include the bundlet
require_once('alfred.bundler.php');
3. Instantiate a Bundler object.
$b = new AlfredBundler;
$b->library('Workflows.php');
$tn = $b->utility('Terminal-Notifier');
$icon = $b->icon('elusive', 'fire', '000000');
$b->composer(['monolog/monolog' => '1.0.*']);
$cd = $b->wrapper('cocoadialog');
$b->notify('Message', 'Title', '/path/to/icon');
For general information on logging with the Bundler, read the log page.
In order to use the logs, you need to initialize the bundler differently:
require_once('alfred.bundler.php');
$b = new AlfredBundler(['wf_log' => true]);
wf_log
key will give you access to console logs as well as a default file log located in the workflow’s data directory named {workflow-bundle-id}.log
. So, if your workflow’s bundle id is com.spr.bundler.example
. The log will be located at ~/Library/Application Support/Alfred 2/Workflow Data/com.spr.bundler.example/com.spr.bundler.example.log
.
After that, to log a message, you can use
$b->log('My log message', 'info', 'both');
That will log the message at level “info” in both the console and the file log.
console
, file
, or both
. The valid log levels are debug
, info
, warning
, error
, critical
. If you input an invalid log level, then an error will be logged to the console, and the log level will fallback to info
.
There are shortcut functions available too...
$b->console('My log message', 'critical');
message
, destination
), although the second is optional. If you do not specify a log destination, it will fallback to console
.
$b->debug('My debug message');
$b->info('My info message', 'file');
$b->warning('My warning message', 'console');
$b->error('My error message');
$b->critical('My critical error message', 'both');
Post on the Alfred Forum thread.
Open an issue in the Github queue.