Skip to content

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

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

Merged
merged 4 commits into from
Feb 15, 2023
Merged
Changes from 2 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
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