Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

expose a logger option to start_reloader #49

Merged
merged 2 commits into from
Mar 7, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ unreleased
receive a ``SIGKILL``.
See https://github.com/Pylons/hupper/pull/48

- Support a ``logger`` argument to ``hupper.start_reloader`` to override
the default logger that outputs messages to ``sys.stderr``.
See https://github.com/Pylons/hupper/pull/49

1.5 (2019-02-16)
================

Expand Down
4 changes: 4 additions & 0 deletions docs/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@
:members:
:special-members:

.. autoclass:: ILogger
:members:
:special-members:

.. automodule:: hupper.polling

.. autoclass:: PollingFileMonitor
Expand Down
9 changes: 6 additions & 3 deletions src/hupper/reloader.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from __future__ import print_function

import fnmatch
import os
import re
Expand Down Expand Up @@ -277,6 +275,7 @@ def start_reloader(
reload_interval=1,
shutdown_interval=default,
verbose=1,
logger=None,
monitor_factory=None,
worker_args=None,
worker_kwargs=None,
Expand Down Expand Up @@ -306,6 +305,9 @@ def start_reloader(
``verbose`` controls the output. Set to ``0`` to turn off any logging
of activity and turn up to ``2`` for extra output. Default is ``1``.

``logger``, if supplied, supersedes ``verbose`` and should be an object
implementing :class:`hupper.interfaces.ILogger`.

``monitor_factory`` is an instance of
:class:`hupper.interfaces.IFileMonitorFactory`. If left unspecified, this
will try to create a :class:`hupper.watchdog.WatchdogFileMonitor` if
Expand All @@ -324,7 +326,8 @@ def start_reloader(
if is_active():
return get_reloader()

logger = DefaultLogger(verbose)
if logger is None:
logger = DefaultLogger(verbose)

if monitor_factory is None:
monitor_factory = find_default_monitor_factory(logger)
Expand Down