@@ -119,12 +119,12 @@ function action() {
119119
120120 if eval " ${action} " ; then
121121 if [ " ${verbose} " -gt " 0" ]; then
122- printf " [%s] [OK] %s succeeded: %s\n" " $( date ' +%Y-%m-%d %H:%M:%S' ) " " ${info} " " ${directory} "
122+ printf " %s: [%s] [OK] %s succeeded: %s\n" " ${MY_NAME} " " $( date ' +%Y-%m-%d %H:%M:%S' ) " " ${info} " " ${directory} "
123123 fi
124124 return 0
125125 else
126126 if [ " ${verbose} " -gt " 0" ]; then
127- printf " [%s] [ERR] %s failed: %s\n" " $( date ' +%Y-%m-%d %H:%M:%S' ) " " ${info} " " ${directory} "
127+ printf " %s: [%s] [ERR] %s failed: %s\n" " ${MY_NAME} " " $( date ' +%Y-%m-%d %H:%M:%S' ) " " ${info} " " ${directory} "
128128 fi
129129 return 1
130130 fi
@@ -140,12 +140,12 @@ function trigger() {
140140 if [ " ${changes} " -eq " 1" ]; then
141141 if eval " ${action} " ; then
142142 if [ " ${verbose} " -gt " 0" ]; then
143- printf " [%s] [OK] %s succeeded: %s\n" " $( date ' +%Y-%m-%d %H:%M:%S' ) " " TRIGGER" " ${action} "
143+ printf " %s: [%s] [OK] %s succeeded: %s\n" " ${MY_NAME} " " $( date ' +%Y-%m-%d %H:%M:%S' ) " " TRIGGER" " ${action} "
144144 fi
145145 return 0
146146 else
147147 if [ " ${verbose} " -gt " 0" ]; then
148- printf " [%s] [ERR] %s failed: %s\n" " $( date ' +%Y-%m-%d %H:%M:%S' ) " " TRIGGER" " ${action} "
148+ printf " %s: [%s] [ERR] %s failed: %s\n" " ${MY_NAME} " " $( date ' +%Y-%m-%d %H:%M:%S' ) " " TRIGGER" " ${action} "
149149 fi
150150 # Also return 0 here in order to not abort the loop
151151 return 0
256256# Main entrypoint
257257# ###########################################################
258258
259- CHANGES=0
259+ # Log startup
260+ if [ " ${VERBOSE} " -gt " 0" ]; then
261+ printf " %s: [%s] Starting daemon.\n" " ${MY_NAME} " " $( date ' +%Y-%m-%d %H:%M:%S' ) "
262+ fi
260263
264+
265+ CHANGES=0
261266ALL_DIRS=" $( get_subdirs " ${WATCH_DIR} " ) "
262267
263268if [ " ${WITHOUT_SUBSHELL} " -eq " 1" ]; then
@@ -283,7 +288,7 @@ CHANGES=0
283288# Use native inotify
284289if [ " ${WATCHER} " = " inotify" ]; then
285290 if [ " ${VERBOSE} " -gt " 0" ]; then
286- echo " Using native inotify to watch for changes."
291+ printf " %s: [%s] Using native inotify to watch for changes.\n " " ${MY_NAME} " " $( date ' +%Y-%m-%d %H:%M:%S ' ) "
287292 fi
288293 inotifywait \
289294 --quiet \
@@ -308,7 +313,7 @@ if [ "${WATCHER}" = "inotify" ]; then
308313# Use custom inotify
309314else
310315 if [ " ${VERBOSE} " -gt " 0" ]; then
311- echo " Using bash loop to watch for changes."
316+ printf " %s: [%s] Using bash loop to watch for changes.\n " " ${MY_NAME} " " $( date ' +%Y-%m-%d %H:%M:%S ' ) "
312317 fi
313318 while true ; do
314319 # Get all directories
0 commit comments