How to Get to See Full Info of Shell Script Error Notice

Hi,

How to get to see full info of shell script error notice?

image

It should show full message when I click the error.

Thanks

The full error is recorded in the Engine.log file.

Unfortunately, the options for Notifications are limited, and an application can only do one kind of notification, which is annoying, but it is what it is.

1 Like

Not sure if this path varies with macOS versions, but from here I can view the last few (e.g. 5 below) Engine.log entries with an incantation like:

tail -5 ~/Library/logs/Keyboard\ Maestro/Engine.log

4 Likes
2 Likes

For the sake of variety, here's mine:

Tail KBM Engine.log.kmmacros (3.6 KB)

1 Like

Is that macOS version dependent ?

( Still in the last days of 11.7.5 here, and not, I think, able to drag-extend notification rectangles)

Grouping the output lines a bit for legibility.

(Separated by blank lines unless differing only in timestamp)

Recent KM notifications- grouped where differing only in timestamp.kmmacros (4.1 KB)


Expand disclosure triangle to view JS source
(() => {
    "use strict";

    // Last 25 Keyboard Maestro notifications,
    // grouped where differing only in timestamp.

	// Rob Trew 2023

    const main = () =>
        groupOn(
            s => s.slice(20)
        )(
            lines(
                Object.assign(
                    Application.currentApplication(),
                    {includeStandardAdditions: true}
                )
                .doShellScript(
                    [
                        "tail -25 ~/Library/logs/Keyboard\\",
                        "Maestro/Engine.log"
                    ]
                    .join(" ")
                )
            )
        )
        .map(unlines)
        .join("\n\n");

    // --------------------- GENERIC ---------------------


    // groupOn :: (a -> b) -> [a] -> [[a]]
    const groupOn = f =>
    // A list of lists, each containing only elements
    // which return equal values for f,
    // such that the concatenation of these lists is xs.
        xs => 0 < xs.length ? (() => {
            const [h, ...t] = xs;
            const [groups, g] = t.reduce(
                ([gs, a], x) => f(x) === f(a[0]) ? (
                    [gs, [...a, x]]
                ) : [[...gs, a], [x]],
                [[], [h]]
            );

            return [...groups, g];
        })() : [];


    // lines :: String -> [String]
    const lines = s =>
    // A list of strings derived from a single string
    // which is delimited by \n or by \r\n or \r.
        0 < s.length
            ? s.split(/\r\n|\n|\r/u)
            : [];


    // unlines :: [String] -> String
    const unlines = xs =>
    // A single string formed by the intercalation
    // of a list of strings with the newline character.
        xs.join("\n");


    // MAIN ---
    return main();
})();

I'm still using Mojave and cannot comment on upstream versions of macOS...

I am using macOS Ventura here:

There is a Show button but clicking it doesn't do anything. And I am not able to drag down the notification to reveal more. Are you able to do that on Mojave ?

Yes. I believe I already said so.

It seems quite ridiculous that Apple would remove that useful feature...

What I would love is the equivalent of Bash shell’s $?, which contains the exit code of the most recent command (0 means it went ok, nonzero indicates an error). In KM’s case, one could imagine a token called %PreviousActionDidError% whose value would be 0 for “no problem” and 1 for “error encountered”. Then you could have a shell script action capture output (including errors) to a variable, but not exit the macro on error, and then use an if-else action to do “if calculation PreviousActionDidError, then display %Variable%ShellOutput% in a window and exit macro”. This would be really helpful for debugging.