Log It – Quickly Save Plain Text Snippets to One or More Log Files

Log It, v1.0

PURPOSE

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:

  1. Define the Content to preload: Nothing; Clipboard; SafariURL; SafariTitle SafariURL; Clipboard SafariURL; [SafariTitle](SafariURL); [Clipboard](SafariURL)

  2. Optionally change the log file each day.

  3. Replace, prepend, or append to an existing log file.

  4. Optionally add a timestamp prefix to every snippet saved.

  5. Optionally apply markdown syntax: Bold; Italic; Bold Italic; Blockquote; Inline code; Syntax Highlighting

  6. Optionally shorten a URL.

  7. 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 file name.

Logged entries can be confirmed with: Nothing; Sound; Dialog; Sound & Dialog

If Dialog or Sound & Dialog is chosen, the user can then opt to: Do Nothing; Select the log file in the Finder; open the log file using TextEdit.

EXAMPLE USE

When reading webpages, a user could save several excerpts by simply copying portions of each webpage and invoking this macro after each copy.

USAGE
  1. (Optional) From any macOS, copy some text.

  2. Launch this macro. The main dialog will be displayed.

  3. (Optional) Change one or more settings in the main dialog.

  4. Select the one of three buttons: Cancel; Save Settings Only; or OK (default)

  5. If the confirmation dialog was specified to appear, select one of three buttons: Open (o); Select (s); No (default)

DEMONSTRATION

The following video includes more information including five example uses of Log It: youtu.be/Zp-8BHhxPLY

SETTINGS

By default, this macro will save log files to: /iCloud Drive/Log It. This can be changed using the local__Folder variable (just below this comment).

RESETTING

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 Option key).

ACKNOWLEDGEMENTS

Log It was inspired by Brian Kammer's Automators post titled: Quick note taking system, bit.ly/2NjPaXO.

TESTED WITH
  • Big Sur, v11.2.1
  • Keyboard Maestro, v9.2
  • MacBookPro16,1
VERSION HISTORY

1.0 - Initial version


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


The demonstration video mentioned above is available here.

.

Log It.kmmacros (110 KB)

Macro Image

5 Likes

This is great, well done!

1 Like

Wow! What an outstanding Macro!
:+1:

Thanks for sharing.

1 Like

Responding to feedback from @quorm on the Mac Power Users Forum, I've updated Log It.

Log It, Version 2.0:

  • 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.

  • Added option Always to the Auto New Each Day setting.


DOWNLOAD Macro File:
Log It.kmmacros (117 KB)
Note: This Macro was uploaded in a DISABLED state. You must enable before it can be triggered.


Image -- Log It
2 Likes

Excellent. Thank you for version 2.

1 Like

15 posts were split to a new topic: Debugging – System Clipboard Token Not Working