MACRO: Engine.log Tool, v2.1

Main Dialog


Secondary Function


PURPOSE

The primary function of the macro is to use a dialog box to display the latest Keyboard Maestro failure or timeout by searching through the Keyboard Maestro Engine.log. After the latest failure/timeout is displayed, the macro provides an option to back through earlier failures/timeouts.

The dialog box also provides an option to display the log file in the Console application with the error line selected and another option to display the offending action in the Keyboard Maestro editor.

If the hot key trigger includes the Shift key (⇧), or the %TriggerValue% includes recall (see below), the initially displayed failure|timeout will be the one last viewed when the macro previously ran.

A secondary function of this macro is to delete some (or all) entries in the Engine.log via seven reduction methods:
delete ⇨ delete Engine.log
purge:RegEx ⇨ modify Engine.log, retaining all entries except those that match the RegEx
keep:RegEx ⇨ modify Engine.log, retaining all entries that match the RegEx
tail:n ⇨ modify Engine.log, retaining only the latest n entries
today ⇨ modify Engine.log, retaining only entries since midnight
days:n ⇨ modify Engine.log, retaining only the latest n days of entries (e.g., days:2 == since midnight yesterday)
time:YYYY-MM-DD [hh:mm[:ss]] ⇨ modify Engine.log, retaining only records since the specified date/time

Note: In all cases, a copy of the unmodified Engine.log is send the System Trash before the log is deleted or reduced.

These reduction methods become available if the dialog box Reduce button is selected.

RUNNING THIS MACRO WITH PARAMETER

If this macro is run from another macro using the Execute a Macro action (or via AppleScript), and With Parameter is specified, the following keywords will direct the macro to execute accordingly:

recall : the initially displayed failure|timeout will be the one last viewed when the macro previously ran

console : bypass the macro dialog box, i.e., go directly to the Console.app with the failed|timed out action selected
action : bypass the macro dialog box, i.e., go directly to the failed|timed out action in the Keyboard Maestro editor

delete ⇨ delete Engine.log
purge:RegEx ⇨ modify Engine.log, retaining all entries except those that match the RegEx
keep:RegEx ⇨ modify Engine.log, retaining all entries that match the RegEx
tail:n ⇨ modify Engine.log, retaining only the latest n entries
today ⇨ modify Engine.log, retaining only entries since midnight
days:n ⇨ modify Engine.log, retaining only the latest n days of entries (e.g., days:2 == since midnight yesterday)
date:YYYY-MM-DD [hh:mm[:ss]] ⇨ modify Engine.log, retaining only records since the specified date/time

When the above reduction methods complete, a dialog box appears summarizing the status of Engine.log. This dialog box can be suppressed by adding a 0: prefix (i.e., 0:delete).

TESTED WITH

• Keyboard Maestro 11.0
• Sonoma beta 14.2 (23C5030f)/MacBookPro16,1
• Mojave 10.14.16/Macmini6,2
• High Sierra 10.13.6/iMac11,1445

VERSION HISTORY

( expand / collapse )

1.0 - initial version

1.1
a) Improved performance for large Engine.log files.
b) Added Adjustable Variables that can be optionally modified to tune the macro performance.

2.0
a) Changed the macro name from Action Failures & Timeouts in Engine Log to Engine.log Tool.
b) Modified the main dialog box to include the Engine.log entry count and to better highlight the failure|timeout.
c) Renamed the button Log to Console.
d) Modified the logic to minimize the pause required before the Console option Edit > Find > Find... is completed. This change eliminated the need for two of the three Adjustable Variables added in Version 1.1.
e) If the hot key trigger includes the Shift key (⇧) or the %TriggerValue% includes recall, the initially displayed failure|timeout will be the one last viewed when the macro previously ran.
f) Improved performance (slightly) and added a check if Engine.log does not contain any failures|timeouts.
g) If this macro is run from another macro using the Execute a Macro action (or via AppleScript), and With Parameter is specified, the following keywords will direct the macro to execute accordingly:
recall : the initially displayed failure|timeout will be the one last viewed when the macro previously ran

console : bypass the macro dialog box, i.e., go directly to the Console.app with the failed|timed out action selected
action : bypass the macro dialog box, i.e., go directly to the failed|timed out action in the Keyboard Maestro editor

delete : delete Engine.log
purge:RegEx : modify Engine.log, retaining all entries except those that match the RegEx
keep:RegEx : modify Engine.log, retaining all entries that match the RegEx
tail:n : modify Engine.log, retaining only the latest n entries
today : modify Engine.log, retaining only entries since midnight
days:n : modify Engine.log, retaining only the latest n days of entries (e.g., days:2 == since midnight yesterday)
date:YYYY-MM-DD [hh:mm[:ss]] : modify Engine.log, retaining only records since the specified date/time

When the above reduction methods complete, a dialog box appears summarizing the status of Engine.log. This dialog box can be suppressed by adding a 0: prefix (i.e., 0:delete).

2.1
Bug fix: Progress dialogs were being displayed even if Engine.log Tool was being run silently from another calling macro.


Download: Engine.log Tool Macros.kmmacros (295.6 KB)

Macro-Image


Macro-Notes
  • Macros are always disabled when imported into the Keyboard Maestro Editor.
    • The user must ensure the macro is enabled.
    • The user must also ensure the macro's parent macro-group is enabled.

System Information
  • macOS 14.2 (23C5030f) PRE-RELEASE SEED SOFTWARE
  • Keyboard Maestro v11.0.1

Console button: Opens the Console application and automatically finds (thus highlights) the failure or timeout that was displayed in the main dialog.

a


Action button: Opens the Keyboard Maestro application and automatically selects the failure or timeout that was displayed in the main dialog.

b


Reduce button: Displays the menu of seven methods to reduce the size of the Engine.log.

c


tail:n (reduce method) ⇨ modify Engine.log, retaining only the latest n entries

d


purge:RegEx (reduce method) ⇨ modify Engine.log, retaining all entries except those that match the RegEx

e


The Engine.log reduction methods can be triggered from a calling macro. One possible application is to remove entries from frequently run macros that clutter the Engine.log. For example, if macros ABC and XYZ are such macros, these steps could be employed:

  1. Download and install Engine.log Tool Macros (link above).

  2. Duplicate the macro: Engine.log Tool–21 purge:RegEx

Keyboard Maestro Export

  1. Rename the duplicated macro: Engine.log Tool–purge:ABC and XYZ entries silently

  2. Modify the With Parameter in the duplicated macro to purge the entries for ABC and XYZ. (Optionally Engine.log Tool is included to purge Engine.log of this macro as well.) The 0: prefix instructs Engine.log Tool to run silently.

Keyboard Maestro Export

  1. For Engine.log Tool–purge:ABC and XYZ entries silently set a Periodic Trigger.
8 Likes

I’ve been looking to replace the macro I use to show the last few errors and I think this might be the one, Jim! I’ll definitely give this some testing tomorrow. :sunglasses:

1 Like

Very cool, thank you!

My machine (on Monterey) hiccuped trying to paste into the Find field in Console until I added a pause between the Reload and Find Select actions here:

.2 and .3 still hiccuped, but .6 did the trick.

Thanks again :+1:

1 Like

Hi, @evanfuchs; you’re welcome!

Ha, I had the reload in there only for testing and forgot to remove it. If you have time, please disable it and your pause and let me know how that works for you. Thanks!

On first read, I thought that made sense, but it seems I still need the Pause after opening Console, anywhere between the Open and Select "Find..." actions. Even with reload disabled.

1 Like

Thanks for reporting back. I’ll take another look this evening when I return home.

Nice Macro @_jims!

Thank you for sharing.

KC

1 Like

I've updated the OP with Version 1.1 of Action Failures & Timeouts in Engine Log:

  • Improved performance for large Engine.log files.

  • Added Adjustable Variables that can be optionally adjusted to tune the macro performance.

I've updated the OP with Version 2.0 of Engine.log Tool:

  • Changed the macro name from Action Failures & Timeouts in Engine Log to Engine.log Tool.

  • Modified the main dialog box to include the Engine.log entry count and to better highlight the failure|timeout.

  • Renamed the button Log to Console.

  • Modified the logic to minimize the pause required before the Console option Edit > Find > Find... is completed. This change eliminated the need for two of the three Adjustable Variables added in Version 1.1.

  • If the hot key trigger includes the Shift key (⇧) or the %TriggerValue% includes recall, the initially displayed failure|timeout will be the one last viewed when the macro previously ran.

  • Improved performance (slightly) and added a check if Engine.log does not contain any failures|timeouts.

  • If this macro is run from another macro using the Execute a Macro action (or via AppleScript), and With Parameter is specified, the following keywords will direct the macro to execute accordingly:
    recall : the initially displayed failure|timeout will be the one last viewed when the macro previously ran

    console : bypass the macro dialog box, i.e., go directly to the Console.app with the failed|timed out action selected
    action : bypass the macro dialog box, i.e., go directly to the failed|timed out action in the Keyboard Maestro editor

    delete : delete Engine.log
    purge:RegEx : modify Engine.log, retaining all entries except those that match the RegEx
    keep:RegEx : modify Engine.log, retaining all entries that match the RegEx
    tail:n : modify Engine.log, retaining only the latest n entries
    today : modify Engine.log, retaining only entries since midnight
    days:n : modify Engine.log, retaining only the latest n days of entries (e.g., days:2 == since midnight yesterday)
    date:YYYY-MM-DD [hh:mm[:ss]] : modify Engine.log, retaining only records since the specified date/time

    When the above reduction methods complete, a dialog box appears summarizing the status of Engine.log. This dialog box can be suppressed by adding a 0: prefix (i.e., 0:delete).

1 Like

Thanks for the update Jim!

The previous version is my goto tool for tracking down errors so I’m really looking forward to using version 2 with its enhancements.

Snappier name too :wink:

1 Like

I've updated the OP with Version 2.1 of Engine.log Tool:

  • Bug fix: Progress bars were being displayed even if Engine.log Tool was being run silently from another calling macro.

WOW I'm in love, thank you!

1 Like