MACRO: Engine.log Tool, v9.0

Hello Jim :wave:

About your questions in post #24:

Besides the localization issues it turns out that the Display Text Window is not in focus and that it is the key to the issue for not closing it. Here I remind you on the Post from @Tom‘s Action Manipulate a Display Text Window which I use in most of my macros that include the Display Text Action … it allows me do display the window and then close it within the macro without moving the mouse and clicking it beforehand…

Maybe you could borrow some code from there to fix this issue from the Macro.

Speaking about the Console window .. yes I see the Searchbar when opening the App. Always…

I Oren read about issues with the Console Application when it was automated… but I never had any issues on this topic before your macro came into my life …
Maybe this could also be an issue with using KM 10.2 on Monterey 12.7.3 - I don’t know … yes I know that there is a newer Version 12.7.4 of Monterey … but I refused to update because I have also issues with other applications that I want to fix beforehand… there will maybe be also the need installing everything from scratch with a clean install since I think that the Last Bartender 4 update crashed a lot on my Mac by installing the beta instead of the official version.

I complained this issue to the developers but no response from them yet … I also reverted the update using Time Machine and made a restart. But I know still have issues like displaying the hidden bar whenever I am in the menu bar and even quirks like selecting hidden Menubar Applications … - just to mention what I am currently have to live with … this is f* me up … maybe I complain about this to the developers of Bartender.
I am using this Application since my first day I switched over completely from windows years ago - and there was never an issue like this …

Sore dude for not talking about the topic … back to topic again …

Yes … this could be the action I was speaking about… - and now I can tell you that you can actually see that the editor is yelling about how you referred the dictionary… it seems to work but the editor is still yelling because you aren’t using the correct syntax in the Token.

As I wrote about this I was not at home in front of my Mac … therefore I wasn’t able to post any Screenshots…

I hope your questions are answered with this reply …

The other thing we were talking about in PM is in the making … we‘ll see how quick I can get this done for you, too.

Greetings from Germany

Tobias

Hello, @Nr.5-need_input,

After reading your last post and rereading your prior posts in this thread (#19, #23, #25), it's now clear to me that you are providing four categories of feedback:

  1. Misunderstandings about the macro design
  2. Suggested macro changes
  3. Keyboard Maestro Editor behavior
  4. Macro behavior that is not working as designed (on your mac(s))

1. Misunderstandings about the macro design

No, when selecting the Console button the macro is designed to open Console.app and find the failure/timeout displayed in the macro dialog. Once this is completed, the macro cancels itself and Console.app should be in focus. This is demonstrated the OP, Video #2.

Similarly, when selecting the Action button, the macro will complete the respective task and cancel itself. In this case, the Keyboard Maestro editor will be in focus. See the OP, Video #3.

On a related note, suppose you are viewing the fifth from last failure/timeout in the macro dialog (in this case the dialog would indicate: LATEST-5) and you press the Console button. As described above, the macro would do its prescribed tasks and cancel. If you'd like to restart the macro initially displaying the fifth from last failure/timeout, you can use the alternate hot key trigger (one that includes ⇧) or start the macro from another (or Alfred) and specify Recall in the With Parameter.

2. Suggested macro changes

I addressed this suggested change above in #24.

Generalizing the macro to allow easy modification of the window positions is not something I'm planning to do. But you'll see in the above post, I did provide the actions that you could modify if it becomes a priority for you.

3. Keyboard Maestro Editor behavior

Actually, the syntax that I'm using is one of the permitted variants. You'll see this mentioned in the wiki (Variables).

You can also use a short form of just %Variable Name% to include variables as long as the variable exists and has a value and there is no corresponding text token, although generally it is better and clearer to use the longer form %Variable%Variable Name%.

I don't normally use the short form, but I make an exception for the Set Dictionary Value action. Regardless, you see the same Set dictionary field appearance when you use the longer form.

Keyboard Maestro Export

4. Macro behavior that is not working as designed (on your mac(s))

Above in #24 I started to address your observed issue. There I mentioned that I'm not able to reproduce the issue you are seeing but suggested that you run the following AppleScript in the Script Editor (or Script Debugger) and see if the Help window closes.

( expand / collapse )
try
	tell application "System Events"
		tell application process "Keyboard Maestro Engine"
			tell (first window whose name is "Keyboard Maestro - Display Text")
				tell (first button whose role description is "close button")
					perform action "AXPress"
				end tell
			end tell
		end tell
	end tell
end try

The above AppleScript is what is being used currently in the macro.

Here's another similar script that I've successfully used elsewhere and just tested in the macro. It worked as expected. I suggest that you also try it.

( expand / collapse )
try
	tell application "System Events"
		tell application process "Keyboard Maestro Engine"
			tell (first window whose name is "Keyboard Maestro - Display Text")
				tell (first button whose title is "OK")
					perform action "AXPress"
				end tell
			end tell
		end tell
	end tell
end try

Okay, thanks for the link. From there here's a third approach that works in the macro but but is slightly more complicated because it does require a Type a Keystroke action after the Execute an AppleScript action.

Keyboard Maestro Export

Here's the above AppleScript code:

( expand / collapse )
try
	tell application "System Events"
		tell application process "Keyboard Maestro Engine"
			tell window "Keyboard Maestro - Display Text"
				tell button "OK" to set focused to true
			end tell
		end tell
	end tell
end try

If none of those work, then maybe there's some strange interaction that is occurring on your mac(s). Worst case scenario, close the Help manually. :grinning:

Hello Jim :wave:

If this is the desired function then I am sorry for misunderstanding It … But if you reread the whole statement from about this again you probably should get it that this is not going to happen on my machines and where my misunderstanding comes from - and since this seems to be a core function of your Macro this is seriously a huge bug …

Edit: speaking of the huge bug i think this tends to be the issue based on the localization and we are discussing the implementation already via PM.

Many many thanks for this … appreciate this help … :+1::+1::+1:

I am only using the title of your section because my iPhone doesn’t get the whole thing … but back to topic - thank you for reminding me of the short form for the Token - I must have forgotten about that because I don’t have ever used this in all the years I am using Keyboard Maestro. And I will also do it like this in the future.

Yeah the color is still there because the editor has no information about the Value since it is a Local Variable. Okay … getting it my Macro editor sometimes shows me that indicating color and sometimes not … something strange thing is going on here.

For the first and second Variant I gave you the answer yesterday telling you that It will not get closed … maybe you’re right that there is something strange going on …

By the way thanks for option three … I will integrate it to test when I‘ve set up everything from scratch again …

I am going to delete my sync File this time and don’t reenable syncing until I am absolutely sure that my Macros are set up correctly… maybe I messed something up or there is something strange is going on with my sync file…

But first I have to try to sleep a few hours … had a horrible night …

Thank you and Greetings from Germany

Tobias

Upon further review, and common understanding, let's move this issue to the fourth category: 4. Macro behavior that is not working as designed (on your mac(s))

Maybe it's localization, but maybe not. Now that we are on the same page, let's rule out something more fundamental.

When I was testing this macro I noticed that the Console.app Find feature can be painfully slow if the Engine.log is huge. (I did do some edge case testing by dumping thousands of events into the Engine.log).

You can get the Engine.log event count in the main Engine.log Tool main dialog. For example here's what I see:

If your Engine.log is huge (or even if it is not), to simplify testing, please do this:

  1. Within the Keyboard Maestro editor, select Help > Open Logs Folder.

  2. When the Finder opens, rename Engine.log to Engine-2024-03-20.log

  3. Close the Finder.

  4. Trigger the Engine.log Tool macro.

  5. Select the Console button.

  6. Summarize your observations.

These steps will help us troubleshoot the issue you are seeing on your mac. (By the way, if you have easy access to multiple macs, please try these steps on the other macs.)


Thanks, @Nr.5-need_input. Best wishes; here's to better sleep! :zzz:

Suggestion: include this thread's URL in the Comment action, right below the "revised" section to make it easier to find this thread. I saw that you added a link at the bottom, but 1) maybe people will not go all the way down to find it, and 2) the link you included sends the person to the forum itself (general), not this thread.

image

I noticed that Discourse doesn't care much about the title so you can even include this URL and it's still redirecting the person to the right thread:
https://forum.keyboardmaestro.com/t/macro-engine-log-tool/33797 (in case you don't want to include the version in the URL)

Hi, @alltiagocom.

When a macro is not easily found using a forum search (e.g., something I contribute within a thread), I do include such a link. But in cases like this, IMO this is an unnecessary additional step of maintenance because the macro can be easily found using built-in Discourse features.

As you noted, I do add the following at the end of the Version History.

The latest version of this macro is available on the Keyboard Maestro Forum.

This is intended to help remind users that the macro originated on the forum and that there might be a newer version available to download.

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

  • The main dialog has been changed such that all buttons, with the exception of Done, can be selected by typing the first letter of the button label. Done can be selected by pressing <esc>.

  • When the Console or Action buttons are selected, the main dialog no longer closes. Note that it can easily be dismissed with the <esc> key. The Engine.log can be forced to reload, by holding down Control (⌃) when the Console button is clicked. (This could be useful when monitoring a macro under development, however, a more efficient method would likely be the use of tail -F Engine.log available by holding down Command key (⌘) when clicking Done.)

  • With help from @ComplexPoint, added an optional small window that displays the the name of the macro that contains the action that failed or timed out. (There will be a noticeable delay before this small window appears. For more information, see this thread.) By default, this small window will appear for every viewed failure/timeout, but that can be changed with a new SETTING named local_ShowMacroWindow. As the macro is running, this state can be toggled by holding down Option key (⌥) when clicking the Action button. In addition, this small window can be opened on demand for the currently viewed failure/timeout, by holding down the Command key (⌘) when clicking the Action button.

  • Added seven additional options with modifiers: 1-3) the three modifiers mentioned above; 4) retreat or advance by 5 failures/timeouts; 5) retreat or advance by 10 failures/timeouts; 6) delete all log items except the latest n where n = 100 by default; 7) save the latest displayed Failure/Timeout to the Clipboard.

  • Modified the AppleScript used to close the Help window. The revised version is easier to understand; it might help address an issue reported by @Nr.5-need_input.

  • If running macOS Mojave or older, the main dialog vertical dividing lines are slightly shorter.

  • Updated the Help window: 1) added the seven new options, 2) changed the primary font color to a darker grey, changed buttons to red, changed modifiers to a darker grey, and 3) increased the vertical space between bullets.

2 Likes

There's no maintenance involved. As I mentioned, Discourse doesn't really care about the title of the thread. Even if the URL doesn't include the title of the thread, what matters is the number at the end. So as long as the thread is this one and you just update the version, the URL will never change, meaning you just add it to the original macro and won't need to change it ever again.

As you can see, the url below isn't the same as the one on this thread, but if you visit it, it will show you this thread:

https://forum.keyboardmaestro.com/t/macro-engine-log-tool/33797 (what matters is the number 33797)

Even if I completely change the title:
https://forum.keyboardmaestro.com/t/rainny-day/33797

So since you already provide the version at the top of the comment action, you can use a generic link such as
https://forum.keyboardmaestro.com/t/macro-engine-log-tool/33797 (without including the version) and having it at the top makes it even easier to find the thread

Hi again, @alltiagocom.

There's a little. When you first create a macro, you don't know the Discourse URL. So if you want to include it with Version 1.0, you'd have to create a new Macro thread (presumably without the macro), then update the post with the macro (after you've added the link). No, this isn't much, but why add even this little extra maintenance when a macro like this can be easily found using the forum Search?

Also, if one were to include a link and the link text differed from the actual macro version, yes Discourse doesn't err, but less savy Discourse users could get confused.

I don't see it that way, but it was just a suggestion. You can ignore it.
Thank you for the tool, though :+1:

1 Like

This seems like a good time to post a reminder that, in a tutorial, I've shared how I created and use an Alfred Workflow to launch Engine.log Tool. I do this particularly when I want to quickly use one of the alternate functions. Either way, this can be done without taking my hands off the keyboard.



After invoking Alfred, if I type elt, the above three entries appear. There are three, rather than just one, so that all of the alternative functions can be listed in the three entry subtitles:

  1. ⒪ r→recall; c→console; a→action; rd→reduce; cb→clipboard; e→editor; rv→reveal; s→select; t→tail

  2. ⒪ 0d→0:delete; 0p:𝘙𝘦𝘨𝘌𝘹→0:purge:𝘙𝘦𝘨𝘌𝘹; 0k:𝘙𝘦𝘨𝘌𝘹→0:keep:𝘙𝘦𝘨𝘌𝘹; 0t𝘯→0:tail:𝘯

  3. ⒪ 0td→0:today; 0d𝘯→0:days:𝘯; 0tm𝘺𝘺𝘺𝘺-𝘮𝘮-𝘥𝘥 𝘩𝘮𝘮→0:time:𝘺𝘺𝘺𝘺-𝘮𝘮-𝘥𝘥 𝘩𝘮𝘮

So to invoke Engine.log Tool normally, I just press <return>; optionally to use one of alternate functions, I add a <space> and the listed abbreviation. For example, elt d deletes the Engine.log and produces a dialog similar to the following:



Alternatively, the Engine.log can be deleted silently, i.e., without producing the dialog, using: elt 0d

I've updated the OP with Version 8.1 of Engine.log Tool: Per the suggestion of @alltiagocom, included a forum link at the top of the macro. There is no functional change.

1 Like

One thing I believe could be included is a button to copy the current message to the clipboard, which could be useful for example to share it here on the forum.
I'm aware that the "Console" button can be used to do to that, but it's an extra step that could be removed, especially because it takes longer than a button that just copies the message to the clipboard immediately.

And the user could even decide if it shows a notification or not after copying. I always like to have it set that way when I copy things to the clipboard, like this:
✅ XYZ copied to the clipboard!

So the main macro, right after the comment action, could have an action to set a variable to true or false and that would trigger the notification after hitting the Copy to Clipboard button (or not). This would make it easy to change that behavior in the future without diving deep into the macro and try to find the notification.
And it could have another variable action to customize the message being displayed in the notification.

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

  • Changed occurrences of Cancel This Macro to Cancel Just This Macro. This allows macros that call this macro to continue with further processing once this macro ends.

  • Updated the TESTED WITH section.

Hi, @alltiagocom. I considered a dedicated button to populate the clipboard with the displayed failure/timeout, but that obviously would increase the width of an already wide dialog. Since I was particularly concerned for those using a low resolution on a laptop, I decided against that option.

As the Help window indicates, it's the Done button, not the Console button.

I'm not sure I fully understand your objective, but you can leverage the options described in the header comment in this section: EXECUTING THIS MACRO FROM ANOTHER MACRO AND/OR BY USING APPLESCRIPT

Specifically, you can set the With Parameter to clipboard.

Here's a example that I suspect you could modify to meet your needs.

Download: Engine.log Tool > clipboard.kmmacros (4.1 KB)


Note: If you want to execute actions after an Execute a Macro action (like above), you will need to upgrade to Engine.log Tool, Version 9.0.

Here's a screenshot of my 13" width and at least to me, that wouldn't be a problem. I would rather have that button and having a wider window, than not having the button

I mentioned the Console, because I noticed that it highlights the error and so we could then copy to the clipboard. I wasn't aware of the modifier key. I just tried it holding OPTION and clicking Done, but the current message wasn't copied to the clipboard. Not sure if being on Catalina makes any difference, but it's not working.

Maybe this helps:
When I have stuff being copied to the clipboard, I always like to see a notification mentioning it, such as the message I shared ":white_check_mark: XYZ copied to the clipboard".
Some users may use that "method" as well, some don't, so the macro could include some kind of "setting" that could toggle that ON or OFF by simply using a variable at the top of the macro. If the variable "Local__notificationStatus" is set to "true" it shows a notification after hitting the "Copy to Clipboard" (or if the Option+Done is working as expected). If it's set to "false" then it won't show any notification.
That means that an extra action (Switch or If Then) needs to be added after the action that processes the "Done" button (or the "Copy to Clipboard" button).

Next "setting" is the message in the notification window. To avoid diving deep into the macro to customize the message, that could be added at the top of the macro as well, also with a variable (Local__notificationMessage). That way the user can decide if they want to see a notification or not and what message should be displayed.

Something along these lines:
image

Hope it makes sense.

Anyway, the Option+Done doesn't seem to be working on my end. Can you check if it's the macro itself or if maybe Catalina is the issue?

Thank you

Looks like you are running your 13" at a relatively high resolution. My concern is for those that are using a 13" at a relatively low resolution.

I don't have a 13", but on my 16" at 1168x755 (a.k.a. Larger Text) you can see that the current dialog almost spans the entire width of the display.

If I were to add another button, I highly suspect the dialog would be too wide for those using a 13" at the Larger Text display setting.


What version of Engine.log Tool are you using? What version of Keyboard Maestro?

I have two older Macs and my M1 Pro MacBook Pro 16" running the latest version of Sonoma. Option (⌥) plus the Done button works as expected on all three. With the older two, one is running High Sierra and the other is running Mojave. Since those two predate Catalina and since I'm not doing anything exotic in the macro to achieve this function (just checking the state of the modifier key), I doubt if the source of your issue is Catalina.

Do all of the other modifier-plus-button combinations specified in the Help work as expected? If so, then you could try Command (⌘) plus the Done button. That should display the menu depicted in the sixth screenshot in the Engine.log Tool post. With one more press of <return> the displayed failure/timeout will be saved to the clipboard.


BTW, did you try the macro I shared in my previous reply? If so, did it properly update the clipboard?


Incidentally, I see in your first screenshot that the separator line wraps to the next line. That doesn't occur with Sonoma, but I had noticed the same issue with High Sierra and Mojave. I don't understand why the Prompt For User Input dialog gets rendered differently on the different macOS versions, but maybe @peternlewis could explain.

Anyway, since this isn't an issue with Sonoma and I had noticed the issue with Mojave (and since I didn't have any way to test Catalina, Big Sur, Monterey, or Ventura–the versions in between), I partially addressed the issue by inserting logic to conditionally shorten the length of the separator for Mojave and older. But based on your screenshot, I need to at least change that condition to Catalina (and older). I'll change that in the next version.

Keyboard Maestro Forum Community: If you are running Big Sur, Monterey, or Ventura and you are using Engine.log Tool, please let me know if the separator line wraps to the next line. Thanks!

Probably a different system font (or just minor changes to the system font or its characteristics).

1 Like

Updated to version 9 and this is no longer an issue

Holding OPTION while clicking Done, still doesn't copy to the clipboard.
Holding CMD while clicking Done, opened this empty window the first time I tried it:
image

I tried it a few times again, but now it doesn't show it anymore, and it doesn't copy anything to the clipboard. (neither Option or Command)

I have KM 11.0.3

Ah, thanks for that report. I forgot that I added this logic for all versions prior to Sonoma. The wrapping might not be an issue for versions between Catalina and Sonoma (Big Sur, Monterey, or Ventura) but I didn't have any Macs running those versions to test.


Hum, perplexing! I'm not seeing these issues with any of my three macs, including the two that run macOS versions before Catalina. Also, I've not had anyone else report this issue.

I wonder if you might have something on your system that's causing the issue. To help troubleshoot, I've sent you a PM with a test macro. Please reply via the PM. Thanks.


BTW, did you try the macro I shared in above? If so, did it properly update the clipboard?