Skip to content

Commit

Permalink
Fix werkzeug logging at INFO by forcibly unsetting werkzeug log level (
Browse files Browse the repository at this point in the history
…#2383)

* update werkzeug dep to 0.15.4

* forcibly unset werkzeug logger level to make it inherit TB log level
  • Loading branch information
nfelt authored Jun 25, 2019
1 parent 4797176 commit cde14ef
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 4 deletions.
21 changes: 20 additions & 1 deletion tensorboard/program.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,14 @@
import atexit
from collections import defaultdict
import errno
import inspect
import logging
import os
import signal
import socket
import sys
import threading
import time
import inspect

import absl.logging
import six
Expand Down Expand Up @@ -428,6 +429,7 @@ def __init__(self, wsgi_app, flags):
if self._auto_wildcard:
host = self._get_wildcard_address(port)

self._fix_werkzeug_logging()
try:
super(WerkzeugServer, self).__init__(host, port, wsgi_app)
except socket.error as e:
Expand Down Expand Up @@ -529,5 +531,22 @@ def get_url(self):
return 'http://%s:%d%s/' % (display_host, self.server_port,
self._flags.path_prefix.rstrip('/'))

def _fix_werkzeug_logging(self):
"""Fix werkzeug logging setup so it inherits TensorBoard's log level.
This addresses a change in werkzeug 0.15.0+ [1] that causes it set its own
log level to INFO regardless of the root logger configuration. We instead
want werkzeug to inherit TensorBoard's root logger log level (set via absl
to WARNING by default).
[1]: https://github.com/pallets/werkzeug/commit/4cf77d25858ff46ac7e9d64ade054bf05b41ce12
"""
# Log once at DEBUG to force werkzeug to initialize its singleton logger,
# which sets the logger level to INFO it if is unset, and then access that
# object via logging.getLogger('werkzeug') to durably revert the level to
# unset (and thus make messages logged to it inherit the root logger level).
self.log('debug', 'Fixing werkzeug logger to inherit TensorBoard log level')
logging.getLogger('werkzeug').setLevel(logging.NOTSET)


create_port_scanning_werkzeug_server = with_port_scanning(WerkzeugServer)
7 changes: 4 additions & 3 deletions third_party/python.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,11 @@ def tensorboard_python_workspace():
http_archive(
name = "org_pocoo_werkzeug",
urls = [
"https://files.pythonhosted.org/packages/fe/7f/6d70f765ce5484e07576313897793cb49333dd34e462488ee818d17244af/Werkzeug-0.11.15.tar.gz",
"http://mirror.tensorflow.org/files.pythonhosted.org/packages/59/2d/b24bab64b409e22f026fee6705b035cb0698399a7b69449c49442b30af47/Werkzeug-0.15.4.tar.gz",
"https://files.pythonhosted.org/packages/59/2d/b24bab64b409e22f026fee6705b035cb0698399a7b69449c49442b30af47/Werkzeug-0.15.4.tar.gz",
],
strip_prefix = "Werkzeug-0.11.15",
sha256 = "455d7798ac263266dbd38d4841f7534dd35ca9c3da4a8df303f8488f38f3bcc0",
strip_prefix = "Werkzeug-0.15.4",
sha256 = "a0b915f0815982fb2a09161cb8f31708052d0951c3ba433ccc5e1aa276507ca6",
build_file = str(Label("//third_party:werkzeug.BUILD")),
)

Expand Down

0 comments on commit cde14ef

Please sign in to comment.