move AI process lifetime logging
This commit is contained in:
parent
9411735026
commit
95075af3c7
|
@ -13,13 +13,12 @@ final class PlayFSM(
|
|||
extends Actor with AkkaFSM[State, Data] {
|
||||
|
||||
var process: Process = _
|
||||
|
||||
override def preStart() {
|
||||
log.warning("PlayFSM initialize")
|
||||
|
||||
override def preStart() {
|
||||
process = processBuilder(
|
||||
out ⇒ self ! Out(out),
|
||||
err ⇒ self ! Err(err),
|
||||
msg ⇒ !isNoise(msg))
|
||||
out ⇒ self ! Out(out),
|
||||
err ⇒ self ! Err(err),
|
||||
msg ⇒ !isNoise(msg))
|
||||
}
|
||||
|
||||
startWith(Starting, Todo())
|
||||
|
@ -73,7 +72,6 @@ final class PlayFSM(
|
|||
t.isEmpty || (t startsWith "id ") || (t startsWith "info ") || (t startsWith "option name ")
|
||||
|
||||
override def postStop() {
|
||||
log.warning("PlayFSM terminate")
|
||||
process.destroy()
|
||||
process = null
|
||||
}
|
||||
|
|
|
@ -12,6 +12,8 @@ final class Process(
|
|||
err: String ⇒ Unit,
|
||||
debug: Process.Debug) {
|
||||
|
||||
doLog("Start process")
|
||||
|
||||
def write(msg: String) {
|
||||
log(msg)
|
||||
in write (msg + "\n").getBytes("UTF-8")
|
||||
|
@ -19,6 +21,7 @@ final class Process(
|
|||
}
|
||||
|
||||
def destroy() {
|
||||
doLog("Destroy process")
|
||||
try {
|
||||
write("stop")
|
||||
write("quit")
|
||||
|
@ -46,7 +49,11 @@ final class Process(
|
|||
private val process = builder run processIO
|
||||
|
||||
private def log(msg: String) {
|
||||
if (debug(msg)) println("[%s] %s".format(name, msg))
|
||||
if (debug(msg)) doLog(msg)
|
||||
}
|
||||
|
||||
private def doLog(msg: String) {
|
||||
println("[%s] %s".format(name, msg))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue