log of hazel activity (aka what is shown in notifications)

Posted:
Wed Jul 31, 2024 7:47 am
by cfriend
Hi, is it possible to access the type of activity info usually shown in the notifications? I would like to keep a log of hazels activity (moved x file to y folder, etc) as is usually shown in notifications. I have two computers that occasionally interact with the same folder, so I would like to append that info to a text file so I could refer back and see when something was moved where, even if I were on the other computer. I see the "show a notification" rule, I would basically like to have that same info but "append text to file" if possible.
Re: log of hazel activity (aka what is shown in notification

Posted:
Wed Jul 31, 2024 8:27 am
by Mr_Noodle
You can access the full log by going to Help->View Log.
Re: log of hazel activity (aka what is shown in notification

Posted:
Sun Aug 25, 2024 8:52 pm
by gilby101
I have just started to add a script action to many of my rules. This is in addition (or in place of) the notification action. It creates a daily log file with a single line of text regarding the action.
Action: Run shell script with embedded script.
The script:
#!/bin/zsh
printf "$(date '+%Y-%m-%d %H:%M:%S') Action text $1 \n" >> "/Users/gilby/Logs/Hazel/Hazel-$(date '+%Y-%m-%d').log"
The important bits being:
$(date '+%Y-%m-%d %H:%M:%S'): the date and time formatted as I like it.
Action text $1 \n: Some text specific to the action, the file and a new line.
>> "/Users/gilby/Logs/Hazel/Hazel-$(date '+%Y-%m-%d').log": append the output of the print to a log file with a new file every day with filename formatted with the date.
The "Action text" is tailored to the rule. Everything else is always the same.