Skip to content

Commit f23cc89

Browse files
committed
Watcher.examine: log running task
This logs the tasks being run, and adds `func.repr_str` to the task function, which contains the shell command for string "functions".
1 parent b187d80 commit f23cc89

2 files changed

Lines changed: 13 additions & 2 deletions

File tree

livereload/server.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,11 @@ def alert():
196196
css, but reload on changed css files then only.
197197
"""
198198
if isinstance(func, string_types):
199+
cmd = func
199200
func = shell(func)
201+
func.repr_str = "shell: {}".format(cmd)
202+
elif func:
203+
func.repr_str = str(func)
200204

201205
self.watcher.watch(filepath, func, delay)
202206

livereload/watcher.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,18 @@
99
:license: BSD, see LICENSE for more details.
1010
"""
1111

12-
import os
1312
import glob
13+
import logging
14+
import os
1415
import time
16+
1517
try:
1618
import pyinotify
1719
except ImportError:
1820
pyinotify = None
1921

22+
logger = logging.getLogger('livereload')
23+
2024

2125
class Watcher(object):
2226
"""A file watcher registery."""
@@ -70,10 +74,13 @@ def examine(self):
7074
item = self._tasks[path]
7175
if self.is_changed(path, item['ignore']):
7276
func = item['func']
73-
func and func()
7477
delay = item['delay']
7578
if delay and isinstance(delay, int):
7679
delays.add(delay)
80+
if func:
81+
logger.info("Running task: {} (delay: {})".format(
82+
func.repr_str, delay))
83+
func()
7784

7885
if delays:
7986
delay = max(delays)

0 commit comments

Comments
 (0)