Skip to content

Commit 02dc601

Browse files
proper setup for the fallback logger (#269)
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent 93703e2 commit 02dc601

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

jupyterlab_server/process.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,6 @@ def list2cmdline(cmd_list):
3232
return " ".join(map(pipes.quote, cmd_list))
3333

3434

35-
logging.basicConfig(format="%(message)s", level=logging.INFO)
36-
37-
3835
def which(command, env=None):
3936
"""Get the full path to a command.
4037
@@ -92,7 +89,7 @@ def __init__(self, cmd, logger=None, cwd=None, kill_event=None, env=None, quiet=
9289
if kill_event and kill_event.is_set():
9390
raise ValueError("Process aborted")
9491

95-
self.logger = logger = logger or logging.getLogger("jupyterlab")
92+
self.logger = logger = logger or self.get_log()
9693
self._last_line = ""
9794
if not quiet:
9895
self.logger.info(f"> {list2cmdline(cmd)}")
@@ -180,6 +177,14 @@ def _cleanup(cls):
180177
for proc in list(cls._procs):
181178
proc.terminate()
182179

180+
def get_log(self):
181+
if hasattr(self, "logger") and self.logger:
182+
return self.logger
183+
# fallback logger
184+
self.logger = logging.getLogger("jupyterlab")
185+
self.logger.setLevel(logging.INFO)
186+
return self.logger
187+
183188

184189
class WatchHelper(Process):
185190
"""A process helper for a watch process."""

0 commit comments

Comments
 (0)