Using blowhole to write to the log from scripts and apps, with a new Universal binary

This week I’m releasing new Universal binary versions of each of my command tools – in case you missed it, silnite, the command equivalent of SilentKnight, was released in Universal form last week. Each day, I’m going to explain how you can use them, starting today with blowhole, which empowers almost any scripting system to write messages in the unified log.

One of the most fundamental techniques when writing scripts, particularly debugging them, is writing or ‘printing’ messages. These can report progress through the script, intermediate values, loop counters, and anything else which could help. Although most script development environments provide their own support for runtime messaging, there are times when those aren’t available – for example, when your script runs without fault in that environment, but fails when run outside it.

blowhole is easy to use from any environment which allows you to run commands. It uses the unified log, which is available in all versions of macOS from Sierra onwards, and its messages are easy to filter from the incessant chatter which makes the log so hard to use now. You can even use blowhole for live debugging with the Console app.

My favourite example of an unexpected use of blowhole is from the powerful note-making system Tinderbox. Like many advanced apps, it supports the execution of commands from within its scripting system, which in combination with blowhole adds advanced debugging and performance measurement.

Writing a message in the unified log using blowhole couldn’t be much simpler either:
on its own writes a default message of Blowhole snorted!, which is simple to search for. You control the level of its log entry using one option:
blowhole -e
writes its standard message as an error, for instance. Extend that with your own message as an optional string:
blowhole -e "The widget is broken"
and what you’ll see is a log message containing that string. Assemble that using values taken from variables, counters, or labels and you can add all the detail you want.

It can also perform some special tricks:
blowhole -m 5
writes a series of five separate log entries containing the numbers 1 to 5, useful if you want to assess the response time of the log system. Hint: it’s almost incredibly quick.

blowhole -V "Pressed the Return key"
writes a Signpost of type Event with the given message. Signposts proper are only available in Mojave and later, but blowhole implements ‘pseudo-Signposts’ so that you can still use something functionally similar in Sierra and High Sierra.

blowhole is the only reason that I ever use Apple’s stunted tool Console. Set it to filter its live log display to show only messages for the subsystem co.eclecticlight.blowhole, and all you’ll see are blowhole‘s entries in the log. If you haven’t done that before, type
into its Find box, then set the predicate before that to select Sub-System and =.


You can also set a Predicate in my free log browsers Ulbow or Consolation to read
subsystem == "co.eclecticlight.blowhole"
and perform the same filtering on saved log messages.

blowhole version 9 has been available for over a year, but this article also announces the release of a new version 10, which is a Universal binary, so will run native on both Intel and Apple Silicon Macs. That’s particularly important with command tools, as the last thing that you want on your shiny new Apple Silicon system is a call to any command to have to wait for Rosetta 2 to translate an Intel binary to run on ARM processors.

I’ve already explained how mixing Intel-only apps and tools can pose problems: it’s far better on an Apple Silicon system to run a complete calling chain using a single architecture where you can. This update now makes this possible.

blowhole version 10 is fully notarized, supplied with a convenient Installer package, and full documentation, here: blowhole10
from Downloads above, and from its Product Page.

I hope that it proves useful to you. I will continue to leave its last Intel-only version available from its Product Page, in the event that you encounter any problems with this new version.