improve logging again
This commit is contained in:
@@ -44,7 +44,7 @@ rule = Rule(
|
||||
|
||||
fm = FileManager(
|
||||
rules=[rule],
|
||||
logname="FileManager")
|
||||
logname="filemanager")
|
||||
```
|
||||
FileManager provides a task **fm.task**.
|
||||
|
||||
@@ -60,7 +60,7 @@ s = TaskScheduler(
|
||||
files=True,
|
||||
dirs=False,
|
||||
delay=0,
|
||||
logname="TaskScheduler")
|
||||
logname="scheduler")
|
||||
```
|
||||
TaskScheduler provides two tasks which can be bound to an event in an event map.
|
||||
* **s.schedule**
|
||||
@@ -115,7 +115,7 @@ pyinotifyd expects an instance of Pyinotifyd named **pyinotifyd** defined in the
|
||||
pyinotifyd = Pyinotifyd(
|
||||
watches=[watch],
|
||||
shutdown_timeout=30,
|
||||
logname="Pyinotifyd")
|
||||
logname="daemon")
|
||||
```
|
||||
|
||||
### Logging
|
||||
|
||||
@@ -33,10 +33,10 @@ from pyinotifyd.watch import Watch, EventMap
|
||||
|
||||
|
||||
class Pyinotifyd:
|
||||
def __init__(self, watches=[], shutdown_timeout=30, logname=None):
|
||||
def __init__(self, watches=[], shutdown_timeout=30, logname="daemon"):
|
||||
self.set_watches(watches)
|
||||
self.set_shutdown_timeout(shutdown_timeout)
|
||||
logname = (logname or "daemon")
|
||||
logname = (logname or __name__)
|
||||
self._log = logging.getLogger(logname)
|
||||
self._loop = asyncio.get_event_loop()
|
||||
self._notifiers = []
|
||||
|
||||
@@ -66,7 +66,7 @@ class Rule:
|
||||
|
||||
|
||||
class FileManager:
|
||||
def __init__(self, rules, logname=None):
|
||||
def __init__(self, rules, logname="filemgr"):
|
||||
if not isinstance(rules, list):
|
||||
rules = [rules]
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ from uuid import uuid4
|
||||
|
||||
class _Task:
|
||||
def __init__(self, event, delay, task_id, task, callback=None,
|
||||
logname=None):
|
||||
logname="task"):
|
||||
self._event = event
|
||||
self._path = event.pathname
|
||||
self._delay = delay
|
||||
@@ -59,7 +59,7 @@ class _Task:
|
||||
|
||||
|
||||
class TaskScheduler:
|
||||
def __init__(self, task, files, dirs, delay=0, logname=None):
|
||||
def __init__(self, task, files, dirs, delay=0, logname="sched"):
|
||||
assert callable(task), \
|
||||
f"task: expected callable, got {type(task)}"
|
||||
self._task = task
|
||||
@@ -127,13 +127,12 @@ class TaskScheduler:
|
||||
|
||||
|
||||
class ShellScheduler(TaskScheduler):
|
||||
def __init__(self, cmd, task=None, logname=None, *args, **kwargs):
|
||||
def __init__(self, cmd, task=None, *args, **kwargs):
|
||||
assert isinstance(cmd, str), \
|
||||
f"cmd: expected {type('')}, got {type(cmd)}"
|
||||
self._cmd = cmd
|
||||
|
||||
logname = (logname or __name__)
|
||||
super().__init__(*args, task=self.task, logname=logname, **kwargs)
|
||||
super().__init__(*args, task=self.task, **kwargs)
|
||||
|
||||
async def task(self, event, task_id):
|
||||
maskname = event.maskname.split("|", 1)[0]
|
||||
|
||||
Reference in New Issue
Block a user