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

Clean up logging shim #218

Merged
merged 9 commits into from
Oct 8, 2019
Merged

Clean up logging shim #218

merged 9 commits into from
Oct 8, 2019

Conversation

swlynch99
Copy link
Contributor

This PR rewrites the log shim in ccommon_rs to be both simpler and usable from the rust code. This addresses a few problems with the original log module, namely that

  • It was a beautiful work of art but, unfortunately, it was overkill for the purpose at hand
  • It wasn't possible to usefully initialize it from rust code and instead it had to be initialized through a C API
  • The logger created several temporary files which made unit tests fragile

The new version just passes log messages through to ccommon's debug log. In addition, I've added a panic hook that logs at LOG_CRIT level.

As a result of this, several other changes were made:

  • Strip out several dependencies, notably failure
  • Move some other dependences to dev-dependencies to make compilation faster
  • Rewrite the header files which expose the rust log shim to C
  • Remove some utility functions that weren't used anywhere in the C project (specifically an rm -rf implementation)

@swlynch99 swlynch99 requested a review from brayniac October 8, 2019 00:25
Copy link
Contributor

@brayniac brayniac left a comment

Choose a reason for hiding this comment

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

Overall this looks great! Just a few small things inline below. Really like how trim the dependencies have become in this PR.

rust/ccommon_rs/src/lib.rs Outdated Show resolved Hide resolved
rust/ccommon_rs/src/log/shim.rs Outdated Show resolved Hide resolved
///
/// This is meant to be
pub fn set_panic_handler() {
use backtrace::Backtrace;
Copy link
Contributor

Choose a reason for hiding this comment

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

Will the backtrace dependency be compatible w/ MUSL builds? Can we add x86_64-unknown-linux-musl target to the CI to make sure? I've had problems w/ backtrace + musl historically, but looks like it might be fixed now?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've redone this to use the standard lib's backtrace printing. That should (hopefully) avoid any issues around musl and the backtrace crate

@swlynch99 swlynch99 merged commit 475dda7 into twitter:master Oct 8, 2019
swlynch99 pushed a commit to swlynch99/pelikan-twitter that referenced this pull request Oct 9, 2019
swlynch99 pushed a commit to twitter/pelikan that referenced this pull request Oct 10, 2019
swlynch99 added a commit that referenced this pull request Oct 16, 2019
This originally tested code that was removed in #218 but was missed because the rust parts of the test are never built even when -DHAVE_RUST=1 is specified in the cmake configuration.
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.

2 participants