Skip to content

Add -Ylog: option to enable loggers #4953

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

Closed
Blaisorblade opened this issue Aug 16, 2018 · 3 comments
Closed

Add -Ylog: option to enable loggers #4953

Blaisorblade opened this issue Aug 16, 2018 · 3 comments

Comments

@Blaisorblade
Copy link
Contributor

Currently, enabling a logger requires modifying https://github.com/lampepfl/dotty/blob/61cba970fec1017223ceb37da05f241f011c14d4/compiler/src/dotty/tools/dotc/config/Printers.scala, replacing say val exhaustivity: Printer = noPrinter with val exhaustivity: Printer = default.

This is neither documented nor convenient, and we can't ask users to enable it for bugs they struggle minimizing. We should probably add a -Ylog: setting.

@abeln
Copy link
Contributor

abeln commented Aug 31, 2018

@Blaisorblade
There are two ways I can think of doing this:

  • Keep Printers an object, and turn every printer field (currently a val) into a def with an implicit Context argument (so we can access the new YlogPrinter flag (Ylog is already taken)).

  • Turn Printers into a trait and move it inside the cake for Context. This is more efficient because the printer fields can remain as vals, but maybe cakes are no longer hip?

Do you have a preference?

@allanrenucci
Copy link
Contributor

I think a hard requirement is that this feature should not introduce any overhead when no printer is enabled. So two things to keep in mind:

  • Testing a setting's value is slow. Ideally it should be done only once (not each time you log something)
  • Context is the most allocated object in the compiler, so it should be kept small. That's why we have stuff like ContextBase. So you should not mix Printers with Context but with ContextBase

@OlivierBlanvillain
Copy link
Contributor

There is already a -Ylog option that will print stuff without having to touch the Printers. IIUC the distinction between the two is intentional (for performance reason?), and the Printers logs are meant to be a debugging tool for compiler writers, no something that we want to exposed under a flag.

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

No branches or pull requests

4 participants