This macro provides a method to quickly save plain text snippets to one or more log files. A user can add snippets quickly because the macro writes directly to the text log files, i.e., the user is not required to interact with a separate macOS application.
In addition, using settings included on the main dialog of the macro, a user can customize the logging behavior:
Define the Content to preload:
Nothing; Selection, Clipboard;
SafariURL; SafariTitle SafariURL; Selection SafariURL; Clipboard SafariURL;
[SafariTitle](SafariURL); [Selection](SafariURL); [Clipboard] (SafariURL);
ChromeURL; ChomeTitle ChromeURL; Selection ChromeURL; Clipboard ChromeURL;
[ChomeTitle](ChromeURL); [Selection](ChromeURL); [Clipboard](ChromeURL)
Optionally change the Log Filename each day.
Replace, Prepend, or Append to an existing log file.
Optionally add a Timestamp Prefix to every snippet saved.
Optionally apply Markdown syntax: Bold; Italic; Bold Italic; Blockquote; Inline code; Syntax Highlighting
Optionally Shorten a URL.
Specify a Content Suffix which effectively acts as a delimiter between captures snippets.
The main dialog also provides a field that allows the user to change the Log Filename.
Constructed snippets written to log files can be confirmed with: Sound; Dialog; or Sound & Dialog.
If Dialog or Sound & Dialog are chosen, the user can then opt to: Open (the log file using the default tex editor), Select (the log file in the Finder), or do nothing.
The following video includes more information including five example uses of Log It: youtu.be/Zp-8BHhxPLY. Although several options have been added since the recording, everything within the video still applies.
When reading webpages, a user could save several excerpts by simply selecting portions of each webpage and invoking this macro.
(Optional) From any macOS, select some text.
Launch this macro. The main dialog will be displayed.
(Optional) Change one or more settings in the main dialog.
Select the one of four buttons: Cancel; Save Settings Only; Write to Clipboard; OK. The default, OK, writes the constructed snippet to a log file. Alternatively, Write to Clipboard, updates the macOS Clipboard, not a log file.
If the confirmation dialog was specified to appear, select one of three buttons: Open; Select; No
WRITING TO CLIPBOARD
The primary purpose of this macro is to write text to log files. However, the main dialog includes a Write to Clipboard button that, when selected, the content will be written to the Clipboard rather than a log file. Moreover, if ⌥ (the Option key) is down when the Write to Clipboard button is selected, the Timestamp Prefix and Content Suffix will be excluded.
BYPASS MAIN DIALOG
To bypass the Log It main dialog, trigger the macro by adding the ⌥ (the Option key). This can be particularly useful for logging several text snippets in quick succession.
- By default, this macro will save log files to: /iCloud Drive/Log It. This can be changed using the local__Folder variable.
- By default, this macro will create log files with a txt extension. This can be changed using the local__Extension variable.
Many of the variable values set in the main dialog persist from one use to the next. To reset Log It to the default values, launch it by adding ⌘ (the Command key).
MULTIPLE INSTANCES OF LOG IT
The following Log It values persist, that is, they will be retained from one run to the next: Auto New Each Day, Start With, No Selection Use Clipboard, Mode. Add Timestamp Prefix, Markdown Content, Shorten URL, Content Suffix, Log Filename, Confirm With
If Log It is simply duplicated (e.g., suppose a user wants to write to more than one folder), the values above will be shared between the two copies. These instructions on the Keyboard Maestro forum outline the process to create Log It instances that maintain independent values.
• Monterey, v12.1; Mojave 10.14.16
• Keyboard Maestro, v10.0.2
• MacBookPro16,1, Macmini6,2
1.0 - Initial version
2.0 - a) Added a setting for the file extension; the default is txt. Some users might want to create files with an md or some other extension. b) Added option Always to the Auto New Each Day setting.
3.0 - a) Added and option to bypass the main dialog by adding ⌥ (Option) when launching. b) For loading the default settings, the modifier was changed from ⌥ (Option) to ⌘ (Command).
4.0 - a) For Start With added these options: ChromeURL; ChromeTitle ChromeURL; Clipboard ChromeURL; [ChromeTitle](ChromeURL); [Clipboard](ChromeURL); b) Updated this comment to include the section: MULTIPLE INSTANCES OF LOG IT; c) Bug fix: With Start With corrected the Clipboard SafariURL option: %Clipboard%, not %SystemClipboard% was mistakenly used.
5.0 - a) Added button/option: Write to Clipboard. b) Added Start With options: Selection, Selection SafariURL, [Selection](SafariURL), Selection ChromeURL, [Selection](ChromeURL). c) Added option: if nothing selected replace Selection with Clipboard.
5.1 - fixed the revision date in the macro header comment. No functional changes since v5.0.
DOWNLOAD Macro File:
Log It.kmmacros (221 KB)
Note: This macro was uploaded in a DISABLED state. It must be ENABLED before it can be run. If it does not trigger, the macro group might also need to be ENABLED.
Even if you have no use for the Log It features as described above, if you are a Keyboard Maestro beginner, you might find that this macro is a useful learning tool. It includes actions that:
- set default values for macro settings; these settings are global variables, i.e., variables that retain their values between macro invocations
- determines if the macro trigger included ⌥; if so, reset the macro settings to default values
- check if a file previously exists
- remove a trailing slash in a folder path (if it includes one)
- check if a folder exists; check if it contains 0, 1, or more files
- check if a file can be written to a folder
- check if a filename is in format: YYYY-MM-DD
- check if a filename is in format: YYYY-MM-DD some suffix
- check if a folder includes additional files, i.e., files in addition to the text file being currently used
- display a main dialog that is context sensitive (displays differing text; addition variable fields; different variable choices)
- can conditionally shorten a URL using tinyurl.com (without requiring an API)
Log It includes many Keyboard Maestro standard actions; in addition, it includes several simple uses of the Run Shell Script and the Run AppleScript actions.