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

Setup basic logging #513

Merged
merged 3 commits into from Jan 17, 2018

Conversation

Projects
None yet
5 participants
@torkleyy
Member

torkleyy commented Dec 22, 2017

TODO: decide on a simple logging implementation and initialize it in the Application


This change is Reviewable

@Rhuagh

This comment has been minimized.

Show comment
Hide comment
@Rhuagh

Rhuagh Dec 23, 2017

Member

Reviewed 20 of 20 files at r1.
Review status: all files reviewed at latest revision, all discussions resolved.


Comments from Reviewable

Member

Rhuagh commented Dec 23, 2017

Reviewed 20 of 20 files at r1.
Review status: all files reviewed at latest revision, all discussions resolved.


Comments from Reviewable

@Xaeroxe

This comment has been minimized.

Show comment
Hide comment
@Xaeroxe

Xaeroxe Dec 23, 2017

Member

I like this a lot! Thank you!

Question for @amethyst/engine-devs and @Rhuagh though, A lot of our crates are starting to get these common dependencies, such as log and shrev. Perhaps we should identify our "framework dependencies" and re-export them in core just to make maintenance easier. (Much like I did with cgmath)

Member

Xaeroxe commented Dec 23, 2017

I like this a lot! Thank you!

Question for @amethyst/engine-devs and @Rhuagh though, A lot of our crates are starting to get these common dependencies, such as log and shrev. Perhaps we should identify our "framework dependencies" and re-export them in core just to make maintenance easier. (Much like I did with cgmath)

@torkleyy

This comment has been minimized.

Show comment
Hide comment
@torkleyy

torkleyy Dec 23, 2017

Member

We have to be careful though because if we do this with private dependencies (which log is) we would have to make a breaking change when we upgrade them.

Member

torkleyy commented Dec 23, 2017

We have to be careful though because if we do this with private dependencies (which log is) we would have to make a breaking change when we upgrade them.

@torkleyy

This comment has been minimized.

Show comment
Hide comment
@torkleyy

torkleyy Dec 24, 2017

Member

So..any suggestions for the logger implementation?

Member

torkleyy commented Dec 24, 2017

So..any suggestions for the logger implementation?

@Xaeroxe

This comment has been minimized.

Show comment
Hide comment
@Xaeroxe

Xaeroxe Dec 24, 2017

Member

I'm content with the idea of having to make breaking changes when upgrading log, chances are pretty good users are going to want to log their own things too. (I know I've done this for a few games I've worked on)

Member

Xaeroxe commented Dec 24, 2017

I'm content with the idea of having to make breaking changes when upgrading log, chances are pretty good users are going to want to log their own things too. (I know I've done this for a few games I've worked on)

@torkleyy

This comment has been minimized.

Show comment
Hide comment
@torkleyy

torkleyy Dec 24, 2017

Member

Ah, nicely observed @Xaeroxe. I think it's okay to expose the log crate then 👍

Member

torkleyy commented Dec 24, 2017

Ah, nicely observed @Xaeroxe. I think it's okay to expose the log crate then 👍

@Emilgardis

This comment has been minimized.

Show comment
Hide comment
@Emilgardis

Emilgardis Dec 25, 2017

Contributor

Related
#124
#460

Contributor

Emilgardis commented Dec 25, 2017

Related
#124
#460

@Rhuagh

This comment has been minimized.

Show comment
Hide comment
@Rhuagh

Rhuagh Dec 25, 2017

Member

simple_logger for examples imho.


Review status: :shipit: all files reviewed at latest revision, all discussions resolved, all commit checks successful.


Comments from Reviewable

Member

Rhuagh commented Dec 25, 2017

simple_logger for examples imho.


Review status: :shipit: all files reviewed at latest revision, all discussions resolved, all commit checks successful.


Comments from Reviewable

@torkleyy

This comment has been minimized.

Show comment
Hide comment
@torkleyy

torkleyy Dec 25, 2017

Member

Only problem with that is that the last commit was two years ago :( It looks pretty much like env_logger, so we could as well just use that.

Member

torkleyy commented Dec 25, 2017

Only problem with that is that the last commit was two years ago :( It looks pretty much like env_logger, so we could as well just use that.

@Rhuagh

This comment has been minimized.

Show comment
Hide comment
@Rhuagh

Rhuagh Dec 25, 2017

Member

That or simplelog, I don't mind either. For production games it will likely be log4rs or similar

Member

Rhuagh commented Dec 25, 2017

That or simplelog, I don't mind either. For production games it will likely be log4rs or similar

@Rhuagh

This comment has been minimized.

Show comment
Hide comment
@Rhuagh

Rhuagh Dec 25, 2017

Member

fern looks nice imho

Member

Rhuagh commented Dec 25, 2017

fern looks nice imho

@Rhuagh

This comment has been minimized.

Show comment
Hide comment
@Rhuagh

Rhuagh Jan 3, 2018

Member

Use env_logger for the examples. How far is this from completion?


Review status: :shipit: all files reviewed at latest revision, all discussions resolved, all commit checks successful.


Comments from Reviewable

Member

Rhuagh commented Jan 3, 2018

Use env_logger for the examples. How far is this from completion?


Review status: :shipit: all files reviewed at latest revision, all discussions resolved, all commit checks successful.


Comments from Reviewable

@torkleyy

This comment has been minimized.

Show comment
Hide comment
@torkleyy

torkleyy Jan 3, 2018

Member

This is pretty easy to complete, and I planned to use fern. Just didn't have time for it yet.

Member

torkleyy commented Jan 3, 2018

This is pretty easy to complete, and I planned to use fern. Just didn't have time for it yet.

@Rhuagh

This comment has been minimized.

Show comment
Hide comment
@Rhuagh

Rhuagh Jan 3, 2018

Member

Ok. Use fern, I like that one the best :)

Member

Rhuagh commented Jan 3, 2018

Ok. Use fern, I like that one the best :)

@bors bors bot closed this Jan 6, 2018

@Xaeroxe

This comment has been minimized.

Show comment
Hide comment
@Xaeroxe

Xaeroxe Jan 6, 2018

Member

Bad robot

Member

Xaeroxe commented Jan 6, 2018

Bad robot

@torkleyy

This comment has been minimized.

Show comment
Hide comment
@torkleyy

torkleyy Jan 13, 2018

Member

Example output:

[amethyst::app][INFO] Initializing Amethyst...
[amethyst::app][INFO] Version: v0.5.1-398-g40fa47b
[amethyst::app][INFO] Platform: x86_64-unknown-linux-gnu
[amethyst::app][INFO] Amethyst git commit: 40fa47ba289cc87f5fc927a2939e071adff21af0
[amethyst::app][INFO] Rustc version: 1.25.0-nightly Nightly
[amethyst::app][INFO] Rustc git commit: 51b0b3734cbd0ca58c8be3512d53fce2d95f40dd
[amethyst::app][INFO] Engine is shutting down

Color may be added later.

Member

torkleyy commented Jan 13, 2018

Example output:

[amethyst::app][INFO] Initializing Amethyst...
[amethyst::app][INFO] Version: v0.5.1-398-g40fa47b
[amethyst::app][INFO] Platform: x86_64-unknown-linux-gnu
[amethyst::app][INFO] Amethyst git commit: 40fa47ba289cc87f5fc927a2939e071adff21af0
[amethyst::app][INFO] Rustc version: 1.25.0-nightly Nightly
[amethyst::app][INFO] Rustc git commit: 51b0b3734cbd0ca58c8be3512d53fce2d95f40dd
[amethyst::app][INFO] Engine is shutting down

Color may be added later.

@torkleyy

This comment has been minimized.

Show comment
Hide comment
@torkleyy

torkleyy Jan 13, 2018

Member

I'd say this is ready for merge; we want to add a logging config later, but we can now finally use logging when creating a PR and don't have to use printlns and remove them at the end :)

Member

torkleyy commented Jan 13, 2018

I'd say this is ready for merge; we want to add a logging config later, but we can now finally use logging when creating a PR and don't have to use printlns and remove them at the end :)

@omni-viral

How user may control where those log goes?

@torkleyy

This comment has been minimized.

Show comment
Hide comment
@torkleyy

torkleyy Jan 14, 2018

Member

Atm this will just log to stdout. As I said above, we need to add a logging configuration, but this PR is helpful as is.

Member

torkleyy commented Jan 14, 2018

Atm this will just log to stdout. As I said above, we need to add a logging configuration, but this PR is helpful as is.

@Emilgardis

This comment has been minimized.

Show comment
Hide comment
@Emilgardis

Emilgardis Jan 14, 2018

Contributor

An easy way to make this configurable for now is to add one function to App and change App::new

  • App::new: fn new<P: AsRef<Path>>(path: P, initial_state: T) -> Result<Self>
    uses App::with_logger internally, using the default logger
  • App::with_logger: fn with_logger<P: AsRef<Path>>(path: P, initial_state: T, logger: fern::Dispatch) -> Result<Self>
Contributor

Emilgardis commented Jan 14, 2018

An easy way to make this configurable for now is to add one function to App and change App::new

  • App::new: fn new<P: AsRef<Path>>(path: P, initial_state: T) -> Result<Self>
    uses App::with_logger internally, using the default logger
  • App::with_logger: fn with_logger<P: AsRef<Path>>(path: P, initial_state: T, logger: fern::Dispatch) -> Result<Self>
@Xaeroxe

This is pretty good! I just have a couple nits.

@@ -6,5 +6,5 @@
multisampling: 1,
title: "Sphere example",
visibility: true,
- vsync: true,
+ vsync: false,

This comment has been minimized.

@Xaeroxe

Xaeroxe Jan 15, 2018

Member

Why was this change made?

@Xaeroxe

Xaeroxe Jan 15, 2018

Member

Why was this change made?

This comment has been minimized.

@torkleyy

torkleyy Jan 15, 2018

Member

I forgot to reset it after running the example (glutin bug currently causes a crash when using vsync).

@torkleyy

torkleyy Jan 15, 2018

Member

I forgot to reset it after running the example (glutin bug currently causes a crash when using vsync).

@@ -151,6 +154,8 @@ impl<'a, 'b> Application<'a, 'b> {
/// Advances the game world by one tick.
fn advance_frame(&mut self) {
+ trace!("Advancing frame (`Application::advance_frame`)");

This comment has been minimized.

@Xaeroxe

Xaeroxe Jan 15, 2018

Member

Are we sure we want this? That's rather a lot of logging for anyone who subscribes to trace events. Advancing the frame is somewhat mundane and not really noteworthy.

@Xaeroxe

Xaeroxe Jan 15, 2018

Member

Are we sure we want this? That's rather a lot of logging for anyone who subscribes to trace events. Advancing the frame is somewhat mundane and not really noteworthy.

This comment has been minimized.

@torkleyy

torkleyy Jan 15, 2018

Member

Well you usually filter the logging at this level (if you don't, you shouldn't expect to get only a few lines of output). The whole point of trace is to provide information you'll almost never need, but can be quite helpful to localize a bug in very rare cases.

@torkleyy

torkleyy Jan 15, 2018

Member

Well you usually filter the logging at this level (if you don't, you shouldn't expect to get only a few lines of output). The whole point of trace is to provide information you'll almost never need, but can be quite helpful to localize a bug in very rare cases.

This comment has been minimized.

@Xaeroxe

Xaeroxe Jan 15, 2018

Member

Ok I understand now. Thanks!

@Xaeroxe

Xaeroxe Jan 15, 2018

Member

Ok I understand now. Thanks!

@Rhuagh

This comment has been minimized.

Show comment
Hide comment
@Rhuagh

Rhuagh Jan 15, 2018

Member

Reviewed 2 of 6 files at r2, 6 of 6 files at r3.
Review status: all files reviewed at latest revision, 3 unresolved discussions.


src/app.rs, line 316 at r3 (raw file):

        use rustc_version_runtime;

        fern::Dispatch::new()

Add a with_logger function on ApplicationBuilder, and use this as the fallback in the build function?


Comments from Reviewable

Member

Rhuagh commented Jan 15, 2018

Reviewed 2 of 6 files at r2, 6 of 6 files at r3.
Review status: all files reviewed at latest revision, 3 unresolved discussions.


src/app.rs, line 316 at r3 (raw file):

        use rustc_version_runtime;

        fern::Dispatch::new()

Add a with_logger function on ApplicationBuilder, and use this as the fallback in the build function?


Comments from Reviewable

@Rhuagh

This comment has been minimized.

Show comment
Hide comment
@Rhuagh

Rhuagh Jan 16, 2018

Member

Review status: all files reviewed at latest revision, 2 unresolved discussions.


src/app.rs, line 316 at r3 (raw file):

Previously, Rhuagh (Simon Rönnberg) wrote…

Add a with_logger function on ApplicationBuilder, and use this as the fallback in the build function?

Actually, just put this in a with_default_logger(mut self) -> Self {}


Comments from Reviewable

Member

Rhuagh commented Jan 16, 2018

Review status: all files reviewed at latest revision, 2 unresolved discussions.


src/app.rs, line 316 at r3 (raw file):

Previously, Rhuagh (Simon Rönnberg) wrote…

Add a with_logger function on ApplicationBuilder, and use this as the fallback in the build function?

Actually, just put this in a with_default_logger(mut self) -> Self {}


Comments from Reviewable

@torkleyy

This comment has been minimized.

Show comment
Hide comment
@torkleyy

torkleyy Jan 16, 2018

Member

Problem is we don't get all the initialization messages if the logger setup is in a builder method.

Member

torkleyy commented Jan 16, 2018

Problem is we don't get all the initialization messages if the logger setup is in a builder method.

@Rhuagh

This comment has been minimized.

Show comment
Hide comment
@Rhuagh

Rhuagh Jan 16, 2018

Member

Hrmph, I guess that's true.

Member

Rhuagh commented Jan 16, 2018

Hrmph, I guess that's true.

@Rhuagh

Rhuagh approved these changes Jan 16, 2018

@Xaeroxe

LGTM! Thanks!

bors r+

bors bot added a commit that referenced this pull request Jan 17, 2018

Merge #513
513: Setup basic logging r=Xaeroxe a=torkleyy

TODO: decide on a simple logging implementation and initialize it in the `Application`

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/amethyst/amethyst/513)
<!-- Reviewable:end -->
@bors

This comment has been minimized.

Show comment
Hide comment
@bors

bors bot Jan 17, 2018

Contributor

Timed out

Contributor

bors bot commented Jan 17, 2018

Timed out

@Xaeroxe

This comment has been minimized.

Show comment
Hide comment
@Xaeroxe

Xaeroxe Jan 17, 2018

Member

Reviewed 13 of 20 files at r1, 2 of 6 files at r2, 6 of 6 files at r3.
Review status: all files reviewed at latest revision, 1 unresolved discussion, some commit checks failed.


Comments from Reviewable

Member

Xaeroxe commented Jan 17, 2018

Reviewed 13 of 20 files at r1, 2 of 6 files at r2, 6 of 6 files at r3.
Review status: all files reviewed at latest revision, 1 unresolved discussion, some commit checks failed.


Comments from Reviewable

@Xaeroxe

This comment has been minimized.

Show comment
Hide comment
@Xaeroxe

Xaeroxe Jan 17, 2018

Member

Overriding

Member

Xaeroxe commented Jan 17, 2018

Overriding

@Xaeroxe Xaeroxe merged commit b2e2637 into amethyst:develop Jan 17, 2018

2 of 4 checks passed

bors Timed out
code-review/reviewable 1 discussion left (Rhuagh, torkleyy)
Details
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details

@Xaeroxe Xaeroxe referenced this pull request Jan 18, 2018

Closed

Add logging system #124

@Emilgardis

This comment has been minimized.

Show comment
Hide comment
@Emilgardis

Emilgardis Jan 19, 2018

Contributor

This needs to be documented somewhere. Even though it is roughly implemented, making an effort to document it should make it clearer on how to do this properly.

Contributor

Emilgardis commented Jan 19, 2018

This needs to be documented somewhere. Even though it is roughly implemented, making an effort to document it should make it clearer on how to do this properly.

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