Winit: Logging

Created on 25 May 2018  路  5Comments  路  Source: rust-windowing/winit

Having proper logging would make things easier for everyone, and I assume most people would agree with that. Telling someone to rerun with WINIT_LOG_LEVEL=debug is much better than saying "rebuild against this branch I made that has some println added that are hopefully relevant", which is something I've had to do a few times now.

Is slog the best way to go about adding logging? I'm also in favor of making the sink global, since passing it around would make this much more tedious to implement.

good first issue in progress enhancement

Most helpful comment

I would be interested in seeing the standard logging facade used in winit. This would allow debugging with whatever logging backend an application provides rather than requiring a special environment variable.

All 5 comments

I would be interested in seeing the standard logging facade used in winit. This would allow debugging with whatever logging backend an application provides rather than requiring a special environment variable.

One other thought -- if there is a concern about having logging in hot code paths, winit could potentially add a feature flag to compile out such macro invocations.

Sounds good to me. With just using log, this is going to be quite easy, so I'll probably start adding some stuff next time I want something relaxing to work on.

What is actually needed here? A lot of work has already been done it seems.

Cargo.toml already names log as a dependency and info! is used alongside the other log macros.

There are a few remaining println!s but most are in examples and the few that remain in the code are outcommented.

Should these be removed or switched to info!?

I guess this is one of those features you can't ever complete, can you?

Personally, I'd like that whenever we make something, we log it's ptr. For example, something like "X made colormap, got ptr 0xfffwhatever it is".

In fact, maybe something like apitrace, but for xlib/winapi/etc, so we can easily log what winit passed and got back. This, like apitrace, would likely be implemented outside of winit, of course. Pipe dream, I know.

Was this page helpful?
0 / 5 - 0 ratings