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

Get help. Get answers. Let others lend you a hand.

Moderator: Mr_Noodle

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.
cfriend
 
Posts: 3
Joined: Fri Mar 25, 2016 3:11 pm

You can access the full log by going to Help->View Log.
Mr_Noodle
Site Admin
 
Posts: 11943
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

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.
gilby101
 
Posts: 1
Joined: Mon Oct 21, 2019 4:57 am


Return to Support