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

Move logger to dash namespace, add stream handler once. #2425

Merged
merged 4 commits into from
Feb 15, 2023
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
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,17 @@ This project adheres to [Semantic Versioning](https://semver.org/).

- [#2417](https://github.com/plotly/dash/pull/2417) Add wait_timeout property to customize the behavior of the default wait timeout used for by wait_for_page, fix [#1595](https://github.com/plotly/dash/issues/1595)
- [#2417](https://github.com/plotly/dash/pull/2417) Add the element target text for wait_for_text* error message, fix [#945](https://github.com/plotly/dash/issues/945)
- [#2425](https://github.com/plotly/dash/pull/2425) Add `add_log_handler=True` to Dash init, if you don't want a log stream handler at all.

## Fixed

- [#2417](https://github.com/plotly/dash/pull/2417) Disable the pytest plugin if `dash[testing]` not installed, fix [#946](https://github.com/plotly/dash/issues/946).
- [#2417](https://github.com/plotly/dash/pull/2417) Do not swallow the original error to get the webdriver, easier to know what is wrong after updating the browser but the driver.
- [#2425](https://github.com/plotly/dash/pull/2425) Fix multiple log handler added unconditionally to the logger, resulting in duplicate log message.

## Changed

- [#2425](https://github.com/plotly/dash/pull/2425) Moved the logger namespace to `dash.dash`, as library logger it should be on that namespace instead of the user app.

## [UNRELEASED]

Expand Down
10 changes: 8 additions & 2 deletions dash/dash.py
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,9 @@ class Dash:
:param background_callback_manager: Background callback manager instance
to support the ``@callback(..., background=True)`` decorator.
One of ``DiskcacheManager`` or ``CeleryManager`` currently supported.

:param add_log_handler: Automatically add a StreamHandler to the app logger
if not added previously.
"""

def __init__( # pylint: disable=too-many-statements
Expand Down Expand Up @@ -361,6 +364,7 @@ def __init__( # pylint: disable=too-many-statements
update_title="Updating...",
long_callback_manager=None,
background_callback_manager=None,
add_log_handler=True,
**obsolete,
):
_validate.check_obsolete(obsolete)
Expand Down Expand Up @@ -481,8 +485,10 @@ def __init__( # pylint: disable=too-many-statements
self._long_callback_count = 0
self._background_manager = background_callback_manager or long_callback_manager

self.logger = logging.getLogger(name)
self.logger.addHandler(logging.StreamHandler(stream=sys.stdout))
self.logger = logging.getLogger(__name__)

if not self.logger.handlers and add_log_handler:
self.logger.addHandler(logging.StreamHandler(stream=sys.stdout))

if isinstance(plugins, patch_collections_abc("Iterable")):
for plugin in plugins:
Expand Down