Skip to content

Commit

Permalink
Allow passing in custom logger
Browse files Browse the repository at this point in the history
When used with a notebook, lets us pass in notebook's
configured logger.
  • Loading branch information
yuvipanda committed Dec 28, 2018
1 parent a6c06c3 commit 1d96158
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions simpervisor/process.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,18 @@ class KilledProcessError(Exception):
pass

class SupervisedProcess:
def __init__(self, name, *args, always_restart=False, ready_func=None, ready_timeout=5, **kwargs):
def __init__(self, name, *args, always_restart=False, ready_func=None, ready_timeout=5, log=None,**kwargs):
self.always_restart = always_restart
self.name = name
self._proc_args = args
self._proc_kwargs = kwargs
self.ready_func = ready_func
self.ready_timeout = ready_timeout
self.proc: asyncio.Process = None
if log is None:
self.log = logging.getLogger('simpervisor')
else:
self.log = log

# asyncio.Process has no 'poll', so we keep that state internally
self.running = False
Expand All @@ -39,8 +43,6 @@ def __init__(self, name, *args, always_restart=False, ready_func=None, ready_tim
# signals is synchronous.
self._proc_lock = asyncio.Lock()

self.log = logging.getLogger('simpervisor')

def _debug_log(self, action, message, extras=None):
"""
Log debug message with some added meta information.
Expand Down

0 comments on commit 1d96158

Please sign in to comment.