Fixes #1478 - Append new sLog when reloading in set command.

* Migrate weak reference into logger class so we can test clearing it.
* Ensure new state.log is propoagted into settings on `set` command.
* Fix set test so that it ensures the sLog is relatively stable when
  reloading on set command.
This commit is contained in:
Josh Suereth
2014-08-01 15:04:32 -04:00
parent b393df8acf
commit 49f1529c5a
6 changed files with 37 additions and 4 deletions
+1 -1
View File
@@ -105,8 +105,8 @@ object LogManager {
// construct a Logger that delegates to the global logger, but only holds a weak reference
// this is an approximation to the ideal that would invalidate the delegate after loading completes
private[this] def globalWrapper(s: State): Logger = {
val ref = new java.lang.ref.WeakReference(s.globalLogging.full)
new Logger {
private[this] val ref = new java.lang.ref.WeakReference(s.globalLogging.full)
private[this] def slog: Logger = Option(ref.get) getOrElse sys.error("Settings logger used after project was loaded.")
override val ansiCodesSupported = slog.ansiCodesSupported
+4 -1
View File
@@ -227,7 +227,10 @@ object BuiltinCommands {
def reapply(newSession: SessionSettings, structure: BuildStructure, s: State): State =
{
s.log.info("Reapplying settings...")
val newStructure = Load.reapply(newSession.mergeSettings, structure)(Project.showContextKey(newSession, structure))
// Here, for correct behavior, we also need to re-inject a settings logger, as we'll be re-evaluating settings.
val loggerInject = LogManager.settingsLogger(s)
val withLogger = newSession.appendRaw(loggerInject :: Nil)
val newStructure = Load.reapply(withLogger.mergeSettings, structure)(Project.showContextKey(newSession, structure))
Project.setProject(newSession, newStructure, s)
}
def set = Command(SetCommand, setBrief, setDetailed)(setParser) {