Skip to content

Use a default StreamHandler for all loggers - #623

Closed
dhirschfeld wants to merge 4 commits into
dask:masterfrom
dhirschfeld:dhirschfeld-logging-fix
Closed

dhirschfeld wants to merge 4 commits into
dask:masterfrom
dhirschfeld:dhirschfeld-logging-fix

Conversation

@dhirschfeld

Copy link
Copy Markdown
Contributor
  • Remove use of basicConfig which can affect the root logger

- Remove use of basicConfig which can affect the root logger
@mrocklin

mrocklin commented Nov 2, 2016

Copy link
Copy Markdown
Member

The stream handler apparently isn't dumping out to stdout, hence the error.

Comment thread distributed/utils.py
import logging
from .compatibility import logging_names
logging.basicConfig(format='%(name)s - %(levelname)s - %(message)s',
level=logging.INFO)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if another option might be logging.getLogger('distributed').basicConfig(...)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AFAICS it's not a method on a logging instance?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh well. Hrm, perhaps this is intended to be global and you're expected to just overwrite other people? Perhaps call basicConfig yourself after importing dask.distributed?

My next step here would be to ask on stackoverflow what the right way to do this would be.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

basicConfig or any other global logging configuration is discouraged in libraries. I think configuring only our own loggers is fine.

@dhirschfeld

Copy link
Copy Markdown
Contributor Author

The builds which failed all seemed to hang on test_bokeh - not sure if that's related?

distributed/cli/tests/test_dask_scheduler.py::test_bokeh 

No output has been received in the last 10m0s, this potentially indicates a stalled build or something wrong with the build itself.
The build has been terminated

@mrocklin

mrocklin commented Nov 2, 2016

Copy link
Copy Markdown
Member

The test_bokeh test is waiting on logging information to come out of stdout or stderr. Apparently the StreamLogger isn't dumping to stdout or stderr.

@dhirschfeld

Copy link
Copy Markdown
Contributor Author

I tried passing sys.stdout to the StreamHandler - we'll see what travis thinks of that...

@pitrou

pitrou commented Nov 3, 2016

Copy link
Copy Markdown
Member

@dhirschfeld, you can probably install bokeh and run the tests locally if you don't want to wait for Travis every time.

Comment thread distributed/utils.py Outdated
fmt = logging.Formatter('%(name)s - %(levelname)s - %(message)s')
handler.setFormatter(fmt)

for name, level in config.get('logging', {}).items():

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By default, this won't configure any logger, though? You should add a default configuration for the "distributed" logger, it will be inherited by any child loggers (any "distributed.FOO.BAR").

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This just configures a handler which is then applied to each logger in the loop below.

This is done instead of setting a handler on the root logger (with basicConfig) and letting the distributed logs percolate up.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My point is it doesn't configure any logger if you have nothing in the logging configuration.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, you probably wouldn't ever want all output to be silenced. I'm assuming that the test is failing because no loggers are configured so I've pushed a further change to fall back to basicConfig in that instance. We'll see what travis thinks of that...

I've just been using the GitHub web-interface so its easier for me to simply wait for travis. I can squash the commits if desired when the test pass.

Comment thread distributed/utils.py
logger.addHandler(handler)

# http://stackoverflow.com/questions/21234772/python-tornado-disable-logging-to-stderr
stream = logging.StreamHandler(sys.stderr)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Logging only critical messages seems heavy-handed. This will even silence exceptions when add_callback callbacks are called. I would recommend setting the level to ERROR instead.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pitrou

pitrou commented Nov 9, 2016

Copy link
Copy Markdown
Member

@dhirschfeld, if you are struggling with this PR, do you want me to take over?

@dhirschfeld

Copy link
Copy Markdown
Contributor Author

Please do! I'm at a bit of a loss as to how to both solve my problem and
not break the tests.

There's not too much here so if it's easier to close this and start afresh
feel free to do so also...

On 10 Nov 2016 1:24 am, "Antoine Pitrou" [email protected] wrote:

@dhirschfeld https://github.com/dhirschfeld, if you are struggling with
this PR, do you want me to take over?

—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#623 (comment), or mute
the thread
https://github.com/notifications/unsubscribe-auth/AA1xeyVktR-O8mDcTeAF0ZF38oPnw29fks5q8eWQgaJpZM4Kn17X
.

@pitrou

pitrou commented Nov 16, 2016

Copy link
Copy Markdown
Member

I'm going close this PR as obsoleted by #645.

@pitrou pitrou closed this Nov 16, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants