Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upCreate builders for `Metadata`, `Record`, and `Level`. #200
Conversation
brson
reviewed
Jul 6, 2017
| /// the created object when `build` is called. | ||
| /// | ||
| /// # Example | ||
| /// ```rust |
This comment has been minimized.
This comment has been minimized.
brson
reviewed
Jul 6, 2017
| /// let my_record = RecordBuilder::new(&error_location) | ||
| /// .args(format_args!("Error!")) | ||
| /// .metadata(error_metadata) | ||
| /// .build(); |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
@omh1280 thank you. This all looks right to me with the exception that the builder pattern we tend to prefer is with cc @alexcrichton can you peek at this? Do you agree that the builders should be by ref? |
brson
reviewed
Jul 6, 2017
| /// let mut level_test = MetadataBuilder::new() | ||
| /// .level(Level::Debug) | ||
| /// .target(target) | ||
| /// .build(); |
This comment has been minimized.
This comment has been minimized.
brson
reviewed
Jul 6, 2017
| /// takes a `&Location`. | ||
| /// | ||
| /// # Example | ||
| /// ```rust |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Ah yeah I agree that these should be |
This comment has been minimized.
This comment has been minimized.
|
Gotcha. I'll update next time I get a chance! |
This comment has been minimized.
This comment has been minimized.
|
Fixed!
Thanks for the review |
stephaneyfx
referenced this pull request
Jul 7, 2017
Closed
Support integrating foreign loggers #206
This comment has been minimized.
This comment has been minimized.
|
Thanks @omh1280! ping @alexcrichton |
This comment has been minimized.
This comment has been minimized.
|
Oh, I guess I can continue the review myself... |
This comment has been minimized.
This comment has been minimized.
In this case, this seems fine. I don't see a reason for Record and Metadata not to be Copy/Clone. @alexcrichton what you think? An alternative would be for build to take
Yes.
I suspect this a subtle efficiency matter. This type is passed around during logging and copying one pointer is faster than copying the entire struct. This patch looks fine to me now, but I'd be more confident if @alexcrichton took another look. |
This comment has been minimized.
This comment has been minimized.
|
I think we may want to remove Some other points I'd have:
|
This comment has been minimized.
This comment has been minimized.
|
Thanks Alex! Let me know if it still needs work (or if you want me to rebase to clean up commits) |
This comment has been minimized.
This comment has been minimized.
sfackler
reviewed
Jul 22, 2017
| pub fn new() -> LocationBuilder { | ||
| LocationBuilder { | ||
| location: Location { | ||
| __module_path: module_path!(), |
This comment has been minimized.
This comment has been minimized.
sfackler
Jul 22, 2017
Member
These defaults are not going to be particularly useful - I'd probably lean towards making them empty strings.
This comment has been minimized.
This comment has been minimized.
|
I can't actually remember why It does seem nice to have forwarding methods from the |
This comment has been minimized.
This comment has been minimized.
|
To confirm:
|
This comment has been minimized.
This comment has been minimized.
|
Yep! If we're changing the macros, we may want to change the |
This comment has been minimized.
This comment has been minimized.
|
Sorry for the long wait--I'm in the middle of doing this I promise :) |
This comment has been minimized.
This comment has been minimized.
|
Updated! This was a pretty big change, please let me know if I forgot something.
You now don't have to use super::{Record, Level};
let record = Record::builder()
.module_path("foo")
.file("bar")
.line(30)
.target("myApp") // forwarded
.level(Level::Error) // forwarded
.build();I didn't make |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
Didn't see that--fixed! |
This comment has been minimized.
This comment has been minimized.
|
Looks good to me but it needs a rebase. |
omh1280
force-pushed the
omh1280:record_metadata_construction
branch
from
13f104e
to
f0e2403
Aug 10, 2017
omh1280
force-pushed the
omh1280:record_metadata_construction
branch
from
f0e2403
to
549f47c
Aug 10, 2017
This comment has been minimized.
This comment has been minimized.
|
Squashed + rebased |
omh1280 commentedJun 20, 2017
Fixes #116.
Create builders to support the construction of
Metadata,Record, andLevel. I decided to takemut selfas the parameter for each builder method because it allows:Whereas taking
&mut selfleads to the temporary object created byRecordBuilder::new()being dropped beforebuild().Not done yet--still need to add examples/docs. Please review everything else!