hammerspoon2-docs
    Preparing search index...

    Function consoleHistory

    • Get the messages currently in the Hammerspoon Console, oldest first. This is the same history the Console window shows, so it's limited by the "Console history length" setting (which applies to each level separately), and hs.clearConsole() empties it.

      Each message is an object with:

      • sequence: a number that's higher for each newer message. Pass the last one you've seen as since to get only the messages logged after it
      • date: a Date for when the message was logged
      • level: "garbage", "debug", "info", "warning", "error" or "javascript" (for console.log() and friends)
      • message: the message's text

      Options (all optional):

      • minimumLevel: only get messages at this level or above, e.g. "warning" for warnings and errors (and "javascript" messages, which count as the highest level). Defaults to every level
      • search: only get messages that contain this text, ignoring case
      • since: only get messages whose sequence is higher than this

      Parameters

      • Optionaloptions: {
            minimumLevel?:
                | "garbage"
                | "debug"
                | "info"
                | "warning"
                | "error"
                | "javascript";
            search?: string;
            since?: number;
        }

        Which messages to get

      Returns {
          date: Date;
          level: "garbage" | "debug" | "info" | "warning" | "error" | "javascript";
          message: string;
          sequence: number;
      }[]

      The matching messages, oldest first

      Messages reach the Console asynchronously, so one logged moments ago, including

      Throws an Error on failure; wrap calls in try/catch to handle it.