Skip to content

Made Logger public. - #86

Merged
sfackler merged 1 commit into
rust-lang:masterfrom
asajeffrey:make-env-logger-public
Jul 11, 2016
Merged

sfackler merged 1 commit into
rust-lang:masterfrom
asajeffrey:make-env-logger-public

Conversation

@asajeffrey

Copy link
Copy Markdown

At the moment, the env logger cannot be combined with other loggers, since a) Logger is private, and b) logger creation and registration are combined in one function. This PR fixes those.

Fixes #85.

@asajeffrey

Copy link
Copy Markdown
Author

Should we rename Logger to EnvLogger?

@alexcrichton

Copy link
Copy Markdown
Member

I sort of liked one of the previous iterations where just Box<Log> was returned, perhaps that could be done instead?

@asajeffrey

Copy link
Copy Markdown
Author

The problem is that requires doing an extra dynamic method dispatch on every call to log, you end up with O(N) dynamic calls (where N is the number of loggers) rather than just 1.

@alexcrichton

Copy link
Copy Markdown
Member

Hm ok, seems reasonable to me. Thoughts @sfackler?

I think this may want some more docs, but I wouldn't mind doing so myself as well.

@sfackler

Copy link
Copy Markdown
Member

This seems reasonable to me. One little comment.

Comment thread env/src/lib.rs
builder.build()
}

pub fn filter(&self) -> LogLevelFilter {

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.

Not sure if this should be called filter or something like max_level to match up with the thing passed into init?

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.

filter seems ok to me as the returned type is LogLevelFilter, but I've always been thrown a bit at least when working out the interaction between LogLevel, LogLevelFilter, and the various functions that consume them.

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.

Yeah it's a bit awkward. The split's there to avoid having to deal with
what happens if you log at the "off" level.
On Mon, Jun 27, 2016 at 12:30 PM Alex Crichton [email protected]
wrote:

In env/src/lib.rs
#86 (comment):

@@ -283,6 +280,21 @@ impl LogBuilder {
}

impl Logger {

  • pub fn new() -> Logger {
  •    let mut builder = LogBuilder::new();
    
  •    if let Ok(s) = env::var("RUST_LOG") {
    
  •        builder.parse(&s);
    
  •    }
    
  •    builder.build()
    
  • }
  • pub fn filter(&self) -> LogLevelFilter {

filter seems ok to me as the returned type is LogLevelFilter, but I've
always been thrown a bit at least when working out the interaction between
LogLevel, LogLevelFilter, and the various functions that consume them.

—
You are receiving this because you were mentioned.

Reply to this email directly, view it on GitHub
https://github.com/rust-lang-nursery/log/pull/86/files/415469589ebd0d632758b19aae0d6de051b23ef5#r68609741,
or mute the thread
https://github.com/notifications/unsubscribe/ABY2UbeM0Tj0tviqOvTDsqtQ1eyXWi1iks5qP_qbgaJpZM4I9CHs
.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I think of it as an instance of the usual "counting fence posts" vs "counting gaps" feature.

@asajeffrey

Copy link
Copy Markdown
Author

It might be nice if level was in the Log interface, since that would simplify registering a logger, and make it easier to write log combinators. But that's a separate issue. Is there anything blocking this PR? It's needed for servo/servo#11841.

@asajeffrey

Copy link
Copy Markdown
Author

This is blocking work on Servo logging / error reporting. Can we merge?

@alexcrichton

Copy link
Copy Markdown
Member

@sfackler how do you feel about merging, want to sort out naming issues beforehand?

@sfackler

Copy link
Copy Markdown
Member

No, it seems fine.

@sfackler
sfackler merged commit a95b888 into rust-lang:master Jul 11, 2016
@asajeffrey asajeffrey mentioned this pull request Jul 11, 2016
bors-servo pushed a commit to servo/servo that referenced this pull request Jul 15, 2016
Send log messages to the constellation

<!-- Please describe your changes on the following line: -->

Send all warnings and errors to the constellation. Warnings are bufferred up, and included in any subsequent error reports. Errors are reported in the same way as panics.

Note that this can't merge yet, as it needs rust-lang/log#86 to land.

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [X] These changes fix #11776 (github issue number if applicable).
- [X] These changes do not require tests because we don't test crash reporting.

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="35" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/11841)
<!-- Reviewable:end -->
bors-servo pushed a commit to servo/servo that referenced this pull request Jul 15, 2016
Send log messages to the constellation

<!-- Please describe your changes on the following line: -->

Send all warnings and errors to the constellation. Warnings are bufferred up, and included in any subsequent error reports. Errors are reported in the same way as panics.

Note that this can't merge yet, as it needs rust-lang/log#86 to land.

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [X] These changes fix #11776 (github issue number if applicable).
- [X] These changes do not require tests because we don't test crash reporting.

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="35" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/11841)
<!-- Reviewable:end -->
gecko-dev-updater pushed a commit to marco-c/gecko-dev-comments-removed that referenced this pull request Oct 1, 2019
…ajeffrey:constellation-logging); r=Manishearth

<!-- Please describe your changes on the following line: -->

Send all warnings and errors to the constellation. Warnings are bufferred up, and included in any subsequent error reports. Errors are reported in the same way as panics.

Note that this can't merge yet, as it needs rust-lang/log#86 to land.

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [X] These changes fix #11776 (github issue number if applicable).
- [X] These changes do not require tests because we don't test crash reporting.

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

Source-Repo: https://github.com/servo/servo
Source-Revision: a5cd4b95183da4ae9b754d9d4824bd23f4ad7eb8

UltraBlame original commit: d90b7d6759ec7465e6cf29a5e65c9b4ab954d973
gecko-dev-updater pushed a commit to marco-c/gecko-dev-wordified-and-comments-removed that referenced this pull request Oct 1, 2019
…ajeffrey:constellation-logging); r=Manishearth

<!-- Please describe your changes on the following line: -->

Send all warnings and errors to the constellation. Warnings are bufferred up, and included in any subsequent error reports. Errors are reported in the same way as panics.

Note that this can't merge yet, as it needs rust-lang/log#86 to land.

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [X] These changes fix #11776 (github issue number if applicable).
- [X] These changes do not require tests because we don't test crash reporting.

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

Source-Repo: https://github.com/servo/servo
Source-Revision: a5cd4b95183da4ae9b754d9d4824bd23f4ad7eb8

UltraBlame original commit: d90b7d6759ec7465e6cf29a5e65c9b4ab954d973
gecko-dev-updater pushed a commit to marco-c/gecko-dev-wordified that referenced this pull request Oct 1, 2019
…ajeffrey:constellation-logging); r=Manishearth

<!-- Please describe your changes on the following line: -->

Send all warnings and errors to the constellation. Warnings are bufferred up, and included in any subsequent error reports. Errors are reported in the same way as panics.

Note that this can't merge yet, as it needs rust-lang/log#86 to land.

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [X] These changes fix #11776 (github issue number if applicable).
- [X] These changes do not require tests because we don't test crash reporting.

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

Source-Repo: https://github.com/servo/servo
Source-Revision: a5cd4b95183da4ae9b754d9d4824bd23f4ad7eb8

UltraBlame original commit: d90b7d6759ec7465e6cf29a5e65c9b4ab954d973
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.

Add ability to log to both env_logger and a custom logger

3 participants