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 Dash logger.setLevel to init + remove now redundant startup message #1355

Merged
merged 1 commit into from
Aug 5, 2020
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 CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
All notable changes to `dash` will be documented in this file.
This project adheres to [Semantic Versioning](https://semver.org/).

## [UNRELEASED]
### Added
- [#1355](https://github.com/plotly/dash/pull/1355) Removed redundant log message and consolidated logger initialization. You can now control the log level - for example suppress informational messages from Dash with `app.logger.setLevel(logging.WARNING)`.

## [1.14.0] - 2020-07-27
### Added
- [#1343](https://github.com/plotly/dash/pull/1343) Add `title` parameter to set the
Expand Down
10 changes: 2 additions & 8 deletions dash/dash.py
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,8 @@ def __init__(
if self.server is not None:
self.init_app()

self.logger.setLevel(logging.INFO)

def init_app(self, app=None):
"""Initialize the parts of Dash that require a flask app."""
config = self.config
Expand Down Expand Up @@ -1351,8 +1353,6 @@ def enable_dev_tools(
if dev_tools.silence_routes_logging:
logging.getLogger("werkzeug").setLevel(logging.ERROR)

self.logger.setLevel(logging.INFO)

if dev_tools.hot_reload:
_reload = self._hot_reload
_reload.hash = generate_hash()
Expand Down Expand Up @@ -1624,11 +1624,5 @@ def verify_url_part(served_part, url_part, part_name):
display_url = (protocol, host, ":{}".format(port), path)

self.logger.info("Dash is running on %s://%s%s%s\n", *display_url)
self.logger.info(
" Warning: This is a development server. Do not use app.run_server"
)
self.logger.info(
" in production, use a production WSGI server like gunicorn instead.\n"
)

self.server.run(host=host, port=port, debug=debug, **flask_run_options)
15 changes: 13 additions & 2 deletions tests/unit/test_configs.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os
import logging

import pytest
from flask import Flask
Expand Down Expand Up @@ -256,15 +257,25 @@ def test_port_env_fail_range(empty_environ):
)


def test_no_proxy_success(mocker, caplog, empty_environ):
@pytest.mark.parametrize(
"setlevel_warning", [False, True],
)
def test_no_proxy_success(mocker, caplog, empty_environ, setlevel_warning):
app = Dash()

if setlevel_warning:
app.logger.setLevel(logging.WARNING)

# mock out the run method so we don't actually start listening forever
mocker.patch.object(app.server, "run")

app.run_server(port=8787)

assert "Dash is running on http://127.0.0.1:8787/\n" in caplog.text
STARTUP_MESSAGE = "Dash is running on http://127.0.0.1:8787/\n"
if setlevel_warning:
assert caplog.text is None or STARTUP_MESSAGE not in caplog.text
else:
assert STARTUP_MESSAGE in caplog.text


@pytest.mark.parametrize(
Expand Down