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

Rust logging uses Python logging levels #5528

Merged
merged 3 commits into from Mar 12, 2018

Conversation

Projects
None yet
4 participants
@illicitonion
Copy link
Contributor

illicitonion commented Feb 28, 2018

No description provided.

@illicitonion illicitonion requested review from stuhood and kwlzn Feb 28, 2018

@stuhood
Copy link
Member

stuhood left a comment

Thanks!

@@ -610,6 +605,7 @@ def init_externs():
context = ExternContext(self.ffi, self.lib)
self.lib.externs_set(context._handle,
self.ffi_lib.extern_log,
logger.getEffectiveLevel(),

This comment has been minimized.

@stuhood

stuhood Feb 28, 2018

Member

Should have @kwlzn take a look at this, but: I'm not sure that when the externs are created we actually know what the log level will be. Would need to confirm that the bootstrap options are actually being parsed before the externs are initialized.

This comment has been minimized.

@kwlzn

kwlzn Mar 1, 2018

Member

agree that relying on global state here might be errorprone - a quick integration test might be the best way to confirm/protect this?

This comment has been minimized.

@stuhood

stuhood Mar 1, 2018

Member

Multiple levels of global state, unfortunately... iirc parsing bootstrap options mutates python's log level?

This comment has been minimized.

@illicitonion

illicitonion Mar 9, 2018

Contributor

Added test

@@ -488,51 +500,88 @@ where
output
}

This comment has been minimized.

@stuhood

stuhood Feb 28, 2018

Member

Does our logging code justify a new module at this point?

This comment has been minimized.

@illicitonion

illicitonion Mar 1, 2018

Contributor

I initially had this in a new module, but doing so required me to make either with_externs public, or make a public wrapper around e.log, both of which made me a bit sad... Any ideas/thoughts?

This comment has been minimized.

@stuhood

stuhood Mar 1, 2018

Member

Yea, fine with me. Not sure what the way forward on this will be... other than finding a rule model we like and then pruning the externs to fit it.

@baroquebobcat
Copy link
Contributor

baroquebobcat left a comment

lgtm apart from my finding a comment a little confusing.

// be acquired every time we check whether we should log something.
// Please don't mutate it.
// Please.
static mut LOGGER: FfiLogger = FfiLogger { level_filter: log::LevelFilter::Off };

This comment has been minimized.

@baroquebobcat

baroquebobcat Mar 1, 2018

Contributor

I found the wording here a little confusing. Maybe this would be better?

This is mut so that the max log level can be set via set_externs. But in order to avoid a performance hit, there is no lock guarding it. Please don't mutate it. Please.

This comment has been minimized.

@illicitonion

illicitonion Mar 9, 2018

Contributor

Reworded along those lines

@illicitonion illicitonion force-pushed the twitter:dwagnerhall/rust/logging branch from f26beb8 to 6ef8fa3 Mar 9, 2018

@kwlzn

kwlzn approved these changes Mar 12, 2018

Copy link
Member

kwlzn left a comment

lgtm!

@illicitonion illicitonion merged commit b0dbe49 into pantsbuild:master Mar 12, 2018

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details

@illicitonion illicitonion deleted the twitter:dwagnerhall/rust/logging branch Apr 27, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment