Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to print to stream during sbt setting initialization

Tags:

sbt

I am trying to print a warning message whilst configuring an sbt setting. My initial attempt looks something like this:

setting := {
  val log = streams.value.log
  val condition = //check something
  if (condition) {
    log.warn("Warning, condition! Specific functionality may not work.")
    //some default
  } else {
    //something else
  }
}

However, since streams is a TaskKey, its value can only be accessed from tasks. Furthermore, my setting is reused by other settings therefore I don't have the option of defining it as a task.

Hence my question: what is the best way to print warnings during setting initialization?

like image 875
Jakob Odersky Avatar asked Nov 17 '15 19:11

Jakob Odersky


1 Answers

sLog.value.warn("danger!")

sLog is a SettingKey[Logger] for use from setting initialization.

like image 169
pfn Avatar answered Jan 01 '23 18:01

pfn