Support construction of Records and Metadata #116

Closed
opened 2017-05-19 14:37:33 -05:00 by alexcrichton · 8 comments
alexcrichton commented 2017-05-19 14:37:33 -05:00 (Migrated from github.com)

Testing and "shim loggers" typically want to do this so we should support these constructions! We probably want to have the construction go through builders to ensure that we can flexibly add more fields in the future.

I'm not tagging this issue as "easy" just yet as it's got some API design involved, but if we get a concrete design listed here I think it'd be great to tag this issue as "easy" afterwards for an implementation to come by.

Testing and "shim loggers" typically want to do this so we should support these constructions! We probably want to have the construction go through builders to ensure that we can flexibly add more fields in the future. I'm not tagging this issue as "easy" just yet as it's got some API design involved, but if we get a concrete design listed here I think it'd be great to tag this issue as "easy" afterwards for an implementation to come by.
rap2hpoutre commented 2017-06-05 03:42:18 -05:00 (Migrated from github.com)

@alexcrichton Since LogRecord and LogMetadata were renamed, could you edit the title and replace:

'Support construction of LogRecords and LogMetadata

By:

Support construction of Record and Metadata

It's not really important, but I think it may confuse users (including me!).

@alexcrichton Since `LogRecord` and `LogMetadata` were renamed, could you edit the title and replace: > 'Support construction of `LogRecord`s and `LogMetadata` By: > Support construction of `Record` and `Metadata` It's not really important, but I think it may confuse users (including me!).
sfackler commented 2017-06-05 10:57:28 -05:00 (Migrated from github.com)

Fixed!

Fixed!
ottaviohartman commented 2017-06-14 22:06:31 -05:00 (Migrated from github.com)

I'll begin working on this!

  • Create RecordBuilder and MetadataBuilder structs
  • impl the following setters for MetadataBuilder:
    • level() and target()
  • impl the following setters for RecordBuilder:
    • args(), metadata(), location()
  • impl a build() method for each Builder and returns a Record or a Metadata
  • Update the docs to specify that the use of these builders is for testing and "shim loggers"

Look ok?

I'll begin working on this! - Create `RecordBuilder` and `MetadataBuilder` structs - `impl` the following setters for `MetadataBuilder`: - `level()` and `target()` - `impl` the following setters for `RecordBuilder`: - `args()`, `metadata()`, `location()` - `impl` a `build()` method for each `Builder` and returns a `Record` or a `Metadata` - Update the docs to specify that the use of these builders is for testing and "shim loggers" Look ok?
brson commented 2017-06-15 16:18:57 -05:00 (Migrated from github.com)

@omh1280 that looks reasonable to me. Methods should probably take &mut self.

@omh1280 that looks reasonable to me. Methods should probably take `&mut self`.
ottaviohartman commented 2017-06-19 22:14:11 -05:00 (Migrated from github.com)

I'm not sure how to give an example for creating a Location. It's accessible (pub), but it's hidden from the docs and I think giving an example using it would be a bad decision. It's also a necessary part of constructing a full Record.

Does Location need a builder, too?

I'm not sure how to give an example for creating a [`Location`](https://github.com/rust-lang-nursery/log/blob/master/src/lib.rs#L779). It's accessible (`pub`), but it's hidden from the docs and I think giving an example using it would be a bad decision. It's also a necessary part of constructing a full `Record`. Does `Location` need a builder, too?
sfackler commented 2017-06-19 22:14:41 -05:00 (Migrated from github.com)

Yep

Yep
ottaviohartman commented 2017-06-28 12:19:29 -05:00 (Migrated from github.com)

I've submitted a PR for this!

I've submitted a PR for this!
brson commented 2017-07-05 20:53:27 -05:00 (Migrated from github.com)

Thanks @omh1280! Sorry for the delay 👍

Thanks @omh1280! Sorry for the delay 👍
Sign in to join this conversation.
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
gh-rust-lang/log#116
No description provided.