mirror of https://github.com/sbt/sbt.git
Use logger
This commit is contained in:
parent
a89fcb37ca
commit
5e0b087daa
|
|
@ -45,7 +45,7 @@ private[sbt] final class ConsoleChannel extends CommandChannel {
|
||||||
case Some(src) if src != CommandSource.Human =>
|
case Some(src) if src != CommandSource.Human =>
|
||||||
val s = status.state
|
val s = status.state
|
||||||
s.remainingCommands.headOption map {
|
s.remainingCommands.headOption map {
|
||||||
println(_)
|
System.out.println(_)
|
||||||
}
|
}
|
||||||
case _ => //
|
case _ => //
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ private[sbt] final class NetworkChannel extends CommandChannel {
|
||||||
server match {
|
server match {
|
||||||
case Some(x) => // do nothing
|
case Some(x) => // do nothing
|
||||||
case _ =>
|
case _ =>
|
||||||
server = Some(Server.start("127.0.0.1", port, onCommand))
|
server = Some(Server.start("127.0.0.1", port, onCommand, s.log))
|
||||||
}
|
}
|
||||||
s
|
s
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@ package server
|
||||||
import java.net.{ SocketTimeoutException, InetAddress, ServerSocket }
|
import java.net.{ SocketTimeoutException, InetAddress, ServerSocket }
|
||||||
import java.util.concurrent.ConcurrentLinkedQueue
|
import java.util.concurrent.ConcurrentLinkedQueue
|
||||||
import java.util.concurrent.atomic.AtomicBoolean
|
import java.util.concurrent.atomic.AtomicBoolean
|
||||||
|
import sbt.util.Logger
|
||||||
|
|
||||||
private[sbt] sealed trait ServerInstance {
|
private[sbt] sealed trait ServerInstance {
|
||||||
def shutdown(): Unit
|
def shutdown(): Unit
|
||||||
|
|
@ -15,7 +16,7 @@ private[sbt] sealed trait ServerInstance {
|
||||||
}
|
}
|
||||||
|
|
||||||
private[sbt] object Server {
|
private[sbt] object Server {
|
||||||
def start(host: String, port: Int, onIncommingCommand: Command => Unit): ServerInstance =
|
def start(host: String, port: Int, onIncommingCommand: Command => Unit, log: Logger): ServerInstance =
|
||||||
new ServerInstance {
|
new ServerInstance {
|
||||||
|
|
||||||
val lock = new AnyRef {}
|
val lock = new AnyRef {}
|
||||||
|
|
@ -28,11 +29,11 @@ private[sbt] object Server {
|
||||||
val serverSocket = new ServerSocket(port, 50, InetAddress.getByName(host))
|
val serverSocket = new ServerSocket(port, 50, InetAddress.getByName(host))
|
||||||
serverSocket.setSoTimeout(5000)
|
serverSocket.setSoTimeout(5000)
|
||||||
|
|
||||||
println(s"SBT socket server started at $host:$port")
|
log.info(s"sbt server started at $host:$port")
|
||||||
while (running.get()) {
|
while (running.get()) {
|
||||||
try {
|
try {
|
||||||
val socket = serverSocket.accept()
|
val socket = serverSocket.accept()
|
||||||
println(s"New client connected from: ${socket.getPort}")
|
log.info(s"new client connected from: ${socket.getPort}")
|
||||||
|
|
||||||
val connection = new ClientConnection(socket) {
|
val connection = new ClientConnection(socket) {
|
||||||
override def onCommand(command: Command): Unit = {
|
override def onCommand(command: Command): Unit = {
|
||||||
|
|
@ -63,7 +64,7 @@ private[sbt] object Server {
|
||||||
}
|
}
|
||||||
|
|
||||||
override def shutdown(): Unit = {
|
override def shutdown(): Unit = {
|
||||||
println("Shutting down server")
|
log.info("shutting down server")
|
||||||
running.set(false)
|
running.set(false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue