move AI process lifetime logging

This commit is contained in:
Thibault Duplessis 2012-07-14 14:36:39 +02:00
parent 9411735026
commit 95075af3c7
2 changed files with 13 additions and 8 deletions

View file

@ -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
}

View file

@ -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))
}
}