Skip to content

Commit

Permalink
Merge pull request #2425 from plotly/logging-fix
Browse files Browse the repository at this point in the history
Move logger to dash namespace, add stream handler once.
  • Loading branch information
T4rk1n authored Feb 15, 2023
2 parents ae71e86 + 589c2bb commit f99565f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
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

0 comments on commit f99565f

Please sign in to comment.