Skip to content
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

hides debug/info/warn messages behind a flag #633

Merged
merged 1 commit into from Dec 13, 2016
Merged

hides debug/info/warn messages behind a flag #633

merged 1 commit into from Dec 13, 2016

Conversation

schmitch
Copy link
Contributor

@schmitch schmitch commented Nov 22, 2016

Fixes #632

Problem

When you people reach more and more compiled queries the log gets overhauled whenever doing a sbt clean compile run. This hides the debug/info/warn output behind a flag, so that whenever somebody wants to enable it, they need to run via sbt -Dquill.macro.log=true. (Does not disable, fail and error, maybe I will exclude warn as well?)

More info in Ticket.

P.S.: not sure if this is testable :-(

@getquill/maintainers


def info(msg: String): Unit =
c.info(c.enclosingPosition, msg, force = true)
if (debugEnabled) c.info(c.enclosingPosition, msg, force = true)

def debug[T](v: T): T = {
Copy link
Collaborator

Choose a reason for hiding this comment

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

this method is used only for the development, please remove the condition from it.

Copy link
Contributor

Choose a reason for hiding this comment

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

@fwbrasil Where should it otherwise be? In debug()?

@@ -16,13 +21,13 @@ object Messages {
c.abort(c.enclosingPosition, msg)

def warn(msg: String): Unit =
c.warning(c.enclosingPosition, msg)
if (debugEnabled) c.warning(c.enclosingPosition, msg)
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think we should keep the warnings always enabled.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah that is true

@@ -4,6 +4,11 @@ import scala.reflect.macros.blackbox.{ Context => MacroContext }

object Messages {

private val debugEnabled =
Copy link
Collaborator

Choose a reason for hiding this comment

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

It seems that this will disable the logs by default, is it intentional? I'd prefer to keep them enabled by default.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes this is intentional, I mean our CI system or a clean compile produces over >10k lines on our systems (already).

Copy link
Contributor Author

@schmitch schmitch Nov 28, 2016

Choose a reason for hiding this comment

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

I mean the problem is that it's really not usable as soon as you hit a certain amount of queries, also quill still produces runtime logs for the query, which is more than enough. (this is only compile time removal)

Edit: and it's also possible to use the SqlMirrorContext.

Copy link
Collaborator

Choose a reason for hiding this comment

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

@schmitch This would disable by default one of the most important features that Quill was designed to provide: compile time feedback of the generated query. I still think it should be enabled by default. @getquill/maintainers wdyt?

Copy link
Contributor

Choose a reason for hiding this comment

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

I'd prefer to keep old behavior by default and add instructions about disabling verbose compilation log to README.md. It should have defaults friendly to beginners and later everyone can change settings to their needs. Compile-time query generation is the killer feature that should be demonstrated right after developers setup Quill in their projects.

Copy link
Contributor Author

@schmitch schmitch Dec 1, 2016

Choose a reason for hiding this comment

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

I actually updated the PR and added a ENV variable. Also I flipped the switch, so that logging is now enabled by default, but could be enabled by either setting env or a system property.
Well the best way would be having a way to set the Log Level, but at the moment I don't know any possibility to do so with compile time macro's at least you could disable them with logLevel := Level.Warn but unfortunatly that disable's also all info logs of the scala compiler, so it would be really really great to have a log level for the quill code only, but at the moment I don't know any "good" way to do it.

--

Maybe that's the better solution. But well I actually think it's definitly not the most important feature. Actually once you stop doing 10 liners it actually gets annoying.

@fwbrasil
Copy link
Collaborator

@schmitch sorry for the late feedback. The build is failing because there's a source file unformatted:

https://travis-ci.org/getquill/quill/builds/180329536#L9968

Could you please fix it? Thanks!

@schmitch
Copy link
Contributor Author

Done ;)

@fwbrasil
Copy link
Collaborator

thanks @schmitch!

@fwbrasil fwbrasil merged commit 0160030 into zio:master Dec 13, 2016
@schmitch schmitch deleted the fixes-632 branch February 9, 2017 13:30
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.

None yet

3 participants