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 text 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 ⌥(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 ⌥(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.
- local_DICT. See below: MULTIPLE INSTANCES OF LOG IT
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 ⌘(Command key).
MULTIPLE INSTANCES OF LOG IT
The following Log It values are saved in a KM Dictionary and 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 one wants to write to more than one folder), the values above will be shared between the two copies. To maintain independent settings, change the value of local_DICT from the default value of jsLI_dict, e.g., to jsLI_dict2.
Log It was inspired by Brian Kammer's Automators post titled: Quick note taking system, https://talk.automators.fm/t/quick-note-taking-system/4912.
- Keyboard Maestro, v10.0.2
- Monterey, v12.2.1/MacBookPro16,1
- Mojave 10.14.16/Macmini6,2
- High Sierra 10.13.6/iMac11,1445
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 No functional changes since v5.0. Fixed the revision date in the macro header comment.
5.2 All persistent values are now saved to a single KM Dictionary named jsLI_dict, where js are my initials and LI refers to the name of this macro. For more information about this approach to saving values, refer to Dialog with Dynamic Popup List. In cases where multiple copies of Log It are required (with independent settings), this macro can be copied and the value of local_DICT can be changed in the copy.
DOWNLOAD Macro File:
Log It.kmmacros (228 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 saved to a single KM Dictionary and retain their values between macro invocations
- determines if the macro trigger included ⌘(Command); 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.