reorganize logging

pull/867/merge
Thibault Duplessis 2015-09-01 02:36:08 +02:00
parent 9d895e13b4
commit 321efc6498
55 changed files with 98 additions and 91 deletions

View File

@ -51,7 +51,7 @@ final class Env(
)), name = RouterName)
if (!Env.ai.ServerOnly) {
loginfo("[boot] Preloading modules")
play.api.Logger("boot").info("Preloading modules")
List(Env.socket,
Env.site,
Env.tournament,
@ -78,19 +78,15 @@ final class Env(
Env.shutup, // required to load the actor
Env.relay
)
loginfo("[boot] Preloading complete")
play.api.Logger("boot").info("Preloading complete")
}
if (Env.ai.ServerOnly) println("Running as AI server")
// if (config getBoolean "simulation.enabled") {
// lila.simulation.Env.current.start
// }
}
object Env {
lazy val current = "[boot] app" describes new Env(
lazy val current = "app" boot new Env(
config = lila.common.PlayApp.loadConfig,
system = lila.common.PlayApp.system,
appPath = lila.common.PlayApp withApp (_.path.getCanonicalPath))

View File

@ -3,31 +3,48 @@
<conversionRule conversionWord="coloredLevel" converterClass="play.api.Logger$ColoredLevel" />
<appender name="FILE" class="ch.qos.logback.core.FileAppender">
<file>${application.home}/logs/application.log</file>
<encoder>
<pattern>%date [%level] from %logger in %thread - %message%n%xException</pattern>
</encoder>
</appender>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%coloredLevel %logger{15} - %message%n%xException{10}</pattern>
</encoder>
</appender>
<appender name="ASYNCFILE" class="ch.qos.logback.classic.AsyncAppender">
<appender-ref ref="FILE" />
<appender name="ALLFILE" class="ch.qos.logback.core.FileAppender">
<file>${application.home}/logs/all.log</file>
<encoder><pattern>%date [%level] %logger{15} %message%n%xException</pattern></encoder>
</appender>
<appender name="ASYNCALLFILE" class="ch.qos.logback.classic.AsyncAppender">
<appender-ref ref="ALLFILE" />
</appender>
<appender name="ASYNCSTDOUT" class="ch.qos.logback.classic.AsyncAppender">
<root level="INFO">
<appender-ref ref="ASYNCALLFILE" />
</root>
<logger name="play" level="INFO">
<appender-ref ref="STDOUT" />
</appender>
<logger name="netty" level="INFO" />
<logger name="play" level="INFO" />
<logger name="reactivemongo" level="INFO" />
<logger name="application" level="INFO" />
</logger>
<logger name="reactivemongo" level="INFO">
<appender-ref ref="STDOUT" />
</logger>
<logger name="application" level="INFO">
<appender-ref ref="STDOUT" />
</logger>
<logger name="lila" level="INFO">
<appender-ref ref="STDOUT" />
</logger>
<logger name="boot" level="INFO">
<appender name="FILE" class="ch.qos.logback.core.FileAppender">
<file>${application.home}/logs/boot.log</file>
<encoder><pattern>%date [%level] %message%n%xException</pattern></encoder>
</appender>
</logger>
<logger name="timer" level="DEBUG">
<appender name="FILE" class="ch.qos.logback.core.FileAppender">
<file>${application.home}/logs/timer.log</file>
<encoder><pattern>%date [%level] %message%n%xException</pattern></encoder>
</appender>
</logger>
<!-- Off these ones as they are annoying, and anyway we manage configuration ourself -->
<logger name="com.avaje.ebean.config.PropertyMapLoader" level="OFF" />
@ -35,11 +52,4 @@
<logger name="com.avaje.ebeaninternal.server.lib.BackgroundThread" level="OFF" />
<logger name="com.gargoylesoftware.htmlunit.javascript" level="OFF" />
<root level="INFO">
<appender-ref ref="FILE" />
</root>
<root level="WARN">
<appender-ref ref="STDOUT" />
</root>
</configuration>

View File

@ -60,7 +60,7 @@ final class Env(
object Env {
lazy val current = "[boot] ai" describes new Env(
lazy val current = "ai" boot new Env(
c = lila.common.PlayApp loadConfig "ai",
uciMemo = lila.game.Env.current.uciMemo,
db = lila.db.Env.current,

View File

@ -58,7 +58,7 @@ final class Env(
object Env {
lazy val current = "[boot] analyse" describes new Env(
lazy val current = "analyse" boot new Env(
config = lila.common.PlayApp loadConfig "analyse",
db = lila.db.Env.current,
ai = lila.hub.Env.current.actor.ai,

View File

@ -121,7 +121,7 @@ final class Env(
object Env {
lazy val current = "[boot] api" describes new Env(
lazy val current = "api" boot new Env(
config = lila.common.PlayApp.loadConfig,
db = lila.db.Env.current,
renderer = lila.hub.Env.current.actor.renderer,

View File

@ -44,7 +44,7 @@ final class Env(
object Env {
lazy val current: Env = "[boot] blog" describes new Env(
lazy val current: Env = "blog" boot new Env(
config = lila.common.PlayApp loadConfig "blog",
scheduler = lila.common.PlayApp.scheduler,
messageApi = lila.message.Env.current.api)

View File

@ -36,7 +36,7 @@ final class Env(
object Env {
lazy val current = "[boot] bookmark" describes new Env(
lazy val current = "bookmark" boot new Env(
config = lila.common.PlayApp loadConfig "bookmark",
system = lila.common.PlayApp.system,
db = lila.db.Env.current)

View File

@ -34,7 +34,7 @@ final class Env(
object Env {
lazy val current: Env = "[boot] chat" describes new Env(
lazy val current: Env = "chat" boot new Env(
config = lila.common.PlayApp loadConfig "chat",
db = lila.db.Env.current,
flood = lila.security.Env.current.flood,

View File

@ -36,7 +36,7 @@ final class Env(
object Env {
lazy val current: Env = "[boot] coach" describes new Env(
lazy val current: Env = "coach" boot new Env(
config = lila.common.PlayApp loadConfig "coach",
getPref = lila.pref.Env.current.api.getPrefById,
areFriends = lila.relation.Env.current.api.areFriends,

View File

@ -14,6 +14,7 @@ trait PackageObject extends Steroids with WithFuture {
def nowSeconds: Int = (nowMillis / 1000).toInt
lazy val logger = play.api.Logger("lila")
def logdebug(s: String) { logger debug s }
def loginfo(s: String) { logger info s }
def logwarn(s: String) { logger warn s }
def logerr(s: String) { logger error s }
@ -21,16 +22,14 @@ trait PackageObject extends Steroids with WithFuture {
def fulogwarn(s: String) = fuccess { logwarn(s) }
def fulogerr(s: String) = fuccess { logerr(s) }
implicit final def runOptionT[F[+_], A](ot: OptionT[F, A]): F[Option[A]] = ot.run
// from scalaz. We don't want to import all OptionTFunctions, because of the classh with `some`
// from scalaz. We don't want to import all OptionTFunctions, because of the clash with `some`
def optionT[M[_]] = new (({ type λ[α] = M[Option[α]] })#λ ~>({ type λ[α] = OptionT[M, α] })#λ) {
def apply[A](a: M[Option[A]]) = new OptionT[M, A](a)
}
implicit final class LilaPimpedString(s: String) {
def describes[A](v: => A): A = { loginfo(s); v }
def boot[A](v: => A): A = { play.api.Logger("boot").info(s); v }
}
implicit final class LilaPimpedValid[A](v: Valid[A]) {

View File

@ -4,9 +4,11 @@ object Timer {
def apply[A](name: String)(f: => Fu[A]): Fu[A] = {
val start = nowMillis
loginfo(s"[timer $name] start")
logger debug s"[timer $name] start"
f.addEffects(
err => logwarn(s"[timer $name] failed in ${nowMillis - start}ms - ${err.getMessage}"),
_ => loginfo(s"[timer $name] done in ${nowMillis - start}ms"))
err => logger warn s"[timer $name] failed in ${nowMillis - start}ms - ${err.getMessage}",
_ => logger debug s"[timer $name] done in ${nowMillis - start}ms")
}
private lazy val logger = play.api.Logger("timer")
}

View File

@ -19,7 +19,7 @@ final class Env(
object Env {
lazy val current: Env = "[boot] coordinate" describes new Env(
lazy val current: Env = "coordinate" boot new Env(
config = lila.common.PlayApp loadConfig "coordinate",
db = lila.db.Env.current)
}

View File

@ -36,7 +36,7 @@ final class Env(
object Env {
lazy val current = "[boot] db" describes new Env(
lazy val current = "db" boot new Env(
config = lila.common.PlayApp loadConfig "mongodb",
lifecycle = lila.common.PlayApp.lifecycle)
}

View File

@ -23,7 +23,7 @@ final class Env(
object Env {
lazy val current = "[boot] donation" describes new Env(
lazy val current = "donation" boot new Env(
config = lila.common.PlayApp loadConfig "donation",
db = lila.db.Env.current)
}

View File

@ -81,7 +81,7 @@ object Env {
private def hub = lila.hub.Env.current
lazy val current = "[boot] forum" describes new Env(
lazy val current = "forum" boot new Env(
config = lila.common.PlayApp loadConfig "forum",
db = lila.db.Env.current,
modLog = lila.mod.Env.current.logApi,

View File

@ -46,7 +46,7 @@ final class Env(
object Env {
lazy val current = "[boot] forumSearch" describes new Env(
lazy val current = "forumSearch" boot new Env(
config = lila.common.PlayApp loadConfig "forumSearch",
postApi = lila.forum.Env.current.postApi,
client = lila.search.Env.current.client,

View File

@ -86,7 +86,7 @@ final class Env(
object Env {
lazy val current = "[boot] game" describes new Env(
lazy val current = "game" boot new Env(
config = lila.common.PlayApp loadConfig "game",
db = lila.db.Env.current,
mongoCache = lila.memo.Env.current.mongoCache,

View File

@ -46,7 +46,7 @@ final class Env(
object Env {
lazy val current = "[boot] gameSearch" describes new Env(
lazy val current = "gameSearch" boot new Env(
config = lila.common.PlayApp loadConfig "gameSearch",
system = lila.common.PlayApp.system,
client = lila.search.Env.current.client)

View File

@ -22,7 +22,7 @@ final class Env(
object Env {
lazy val current = "[boot] history" describes new Env(
lazy val current = "history" boot new Env(
config = lila.common.PlayApp loadConfig "history",
mongoCache = lila.memo.Env.current.mongoCache,
db = lila.db.Env.current)

View File

@ -50,7 +50,7 @@ final class Env(config: Config, system: ActorSystem) {
object Env {
lazy val current = "[boot] hub" describes new Env(
lazy val current = "hub" boot new Env(
config = lila.common.PlayApp loadConfig "hub",
system = lila.common.PlayApp.system)
}

View File

@ -98,7 +98,7 @@ object Env {
import lila.common.PlayApp
lazy val current = "[boot] i18n" describes new Env(
lazy val current = "i18n" boot new Env(
config = lila.common.PlayApp loadConfig "i18n",
db = lila.db.Env.current,
system = PlayApp.system,

View File

@ -18,7 +18,7 @@ final class Env(
object Env {
lazy val current = "[boot] importer" describes new Env(
lazy val current = "importer" boot new Env(
config = lila.common.PlayApp loadConfig "importer",
scheduler = lila.common.PlayApp.system.scheduler,
roundMap = lila.round.Env.current.roundMap)

View File

@ -87,7 +87,7 @@ final class Env(
object Env {
lazy val current = "[boot] lobby" describes new Env(
lazy val current = "lobby" boot new Env(
config = lila.common.PlayApp loadConfig "lobby",
db = lila.db.Env.current,
hub = lila.hub.Env.current,

View File

@ -12,7 +12,7 @@ final class Env(config: Config, db: lila.db.Env) {
object Env {
lazy val current = "[boot] memo" describes new Env(
lazy val current = "memo" boot new Env(
lila.common.PlayApp loadConfig "memo",
lila.db.Env.current)
}

View File

@ -49,7 +49,7 @@ final class Env(
object Env {
lazy val current = "[boot] message" describes new Env(
lazy val current = "message" boot new Env(
config = lila.common.PlayApp loadConfig "message",
db = lila.db.Env.current,
shutup = lila.hub.Env.current.actor.shutup,

View File

@ -65,7 +65,7 @@ final class Env(
object Env {
lazy val current = "[boot] mod" describes new Env(
lazy val current = "mod" boot new Env(
config = lila.common.PlayApp loadConfig "mod",
db = lila.db.Env.current,
hub = lila.hub.Env.current,

View File

@ -49,7 +49,7 @@ final class Env(
object Env {
lazy val current = "[boot] monitor" describes new Env(
lazy val current = "monitor" boot new Env(
config = lila.common.PlayApp loadConfig "monitor",
db = lila.db.Env.current,
hub = lila.hub.Env.current,

View File

@ -9,7 +9,7 @@ final class Env(bus: lila.common.Bus, renderer: ActorSelection) {
object Env {
lazy val current = "[boot] notification" describes new Env(
lazy val current = "notification" boot new Env(
bus = lila.common.PlayApp.system.lilaBus,
renderer = lila.hub.Env.current.actor.renderer)
}

View File

@ -45,7 +45,7 @@ final class Env(
object Env {
lazy val current: Env = "[boot] opening" describes new Env(
lazy val current: Env = "opening" boot new Env(
config = lila.common.PlayApp loadConfig "opening",
db = lila.db.Env.current)
}

View File

@ -23,7 +23,7 @@ final class Env(
object Env {
lazy val current: Env = "[boot] playban" describes new Env(
lazy val current: Env = "playban" boot new Env(
config = lila.common.PlayApp loadConfig "playban",
isRematch = lila.game.Env.current.cached.isRematch.get _,
db = lila.db.Env.current)

View File

@ -18,7 +18,7 @@ final class Env(
object Env {
lazy val current = "[boot] pref" describes new Env(
lazy val current = "pref" boot new Env(
config = lila.common.PlayApp loadConfig "pref",
bus = lila.common.PlayApp.system.lilaBus,
db = lila.db.Env.current)

View File

@ -62,7 +62,7 @@ final class Env(
object Env {
lazy val current: Env = "[boot] puzzle" describes new Env(
lazy val current: Env = "puzzle" boot new Env(
config = lila.common.PlayApp loadConfig "puzzle",
db = lila.db.Env.current,
renderer = lila.hub.Env.current.actor.renderer,

View File

@ -35,7 +35,7 @@ final class Env(
object Env {
lazy val current = "[boot] qa" describes new Env(
lazy val current = "qa" boot new Env(
config = lila.common.PlayApp loadConfig "qa",
hub = lila.hub.Env.current,
detectLanguage = DetectLanguage(lila.common.PlayApp loadConfig "detectlanguage"),

View File

@ -59,7 +59,7 @@ final class Env(
object Env {
lazy val current = "[boot] relation" describes new Env(
lazy val current = "relation" boot new Env(
config = lila.common.PlayApp loadConfig "relation",
db = lila.db.Env.current,
hub = lila.hub.Env.current,

View File

@ -127,7 +127,7 @@ final class Env(
object Env {
lazy val current = "[boot] relay" describes new Env(
lazy val current = "relay" boot new Env(
config = lila.common.PlayApp loadConfig "relay",
db = lila.db.Env.current,
system = lila.common.PlayApp.system,

View File

@ -43,7 +43,7 @@ final class Env(
object Env {
lazy val current = "[boot] report" describes new Env(
lazy val current = "report" boot new Env(
config = lila.common.PlayApp loadConfig "report",
db = lila.db.Env.current,
system = lila.common.PlayApp.system,

View File

@ -196,7 +196,7 @@ final class Env(
object Env {
lazy val current = "[boot] round" describes new Env(
lazy val current = "round" boot new Env(
config = lila.common.PlayApp loadConfig "round",
system = lila.common.PlayApp.system,
db = lila.db.Env.current,

View File

@ -17,7 +17,7 @@ final class Env(
object Env {
lazy val current = "[boot] search" describes new Env(
lazy val current = "search" boot new Env(
config = lila.common.PlayApp loadConfig "search",
system = lila.common.PlayApp.system,
scheduler = lila.common.PlayApp.scheduler)

View File

@ -109,7 +109,7 @@ final class Env(
object Env {
lazy val current = "[boot] security" describes new Env(
lazy val current = "security" boot new Env(
config = lila.common.PlayApp loadConfig "security",
db = lila.db.Env.current,
system = lila.common.PlayApp.system,

View File

@ -51,7 +51,7 @@ final class Env(
object Env {
lazy val current = "[boot] setup" describes new Env(
lazy val current = "setup" boot new Env(
config = lila.common.PlayApp loadConfig "setup",
db = lila.db.Env.current,
hub = lila.hub.Env.current,

View File

@ -46,7 +46,7 @@ final class Env(
object Env {
lazy val current: Env = "[boot] shutup" describes new Env(
lazy val current: Env = "shutup" boot new Env(
config = lila.common.PlayApp loadConfig "shutup",
reporter = lila.hub.Env.current.actor.report,
system = lila.common.PlayApp.system,

View File

@ -120,7 +120,7 @@ object Env {
private def hub = lila.hub.Env.current
lazy val current = "[boot] simul" describes new Env(
lazy val current = "simul" boot new Env(
config = lila.common.PlayApp loadConfig "simul",
system = lila.common.PlayApp.system,
scheduler = lila.common.PlayApp.scheduler,

View File

@ -29,7 +29,7 @@ final class Env(
object Env {
lazy val current = "[boot] simulation" describes new Env(
lazy val current = "simulation" boot new Env(
typesafeConfig = lila.common.PlayApp loadConfig "simulation",
featured = lila.tv.Env.current.featured,
lobbyEnv = lila.lobby.Env.current,

View File

@ -22,7 +22,7 @@ final class Env(
object Env {
lazy val current = "[boot] site" describes new Env(
lazy val current = "site" boot new Env(
config = lila.common.PlayApp loadConfig "site",
hub = lila.hub.Env.current,
system = lila.common.PlayApp.system)

View File

@ -35,7 +35,7 @@ final class Env(
object Env {
lazy val current = "[boot] socket" describes new Env(
lazy val current = "socket" boot new Env(
config = lila.common.PlayApp loadConfig "socket",
system = lila.common.PlayApp.system,
scheduler = lila.common.PlayApp.scheduler)

View File

@ -45,7 +45,7 @@ final class Env(config: Config, hub: lila.hub.Env, db: lila.db.Env) {
object Env {
lazy val current = "[boot] team" describes new Env(
lazy val current = "team" boot new Env(
config = lila.common.PlayApp loadConfig "team",
hub = lila.hub.Env.current,
db = lila.db.Env.current)

View File

@ -45,7 +45,7 @@ final class Env(
object Env {
lazy val current = "[boot] teamSearch" describes new Env(
lazy val current = "teamSearch" boot new Env(
config = lila.common.PlayApp loadConfig "teamSearch",
client = lila.search.Env.current.client,
system = lila.common.PlayApp.system)

View File

@ -51,7 +51,7 @@ final class Env(
object Env {
lazy val current = "[boot] timeline" describes new Env(
lazy val current = "timeline" boot new Env(
config = lila.common.PlayApp loadConfig "timeline",
db = lila.db.Env.current,
hub = lila.hub.Env.current,

View File

@ -138,7 +138,7 @@ object Env {
private def hub = lila.hub.Env.current
lazy val current = "[boot] tournament" describes new Env(
lazy val current = "tournament" boot new Env(
config = lila.common.PlayApp loadConfig "tournament",
system = lila.common.PlayApp.system,
db = lila.db.Env.current,

View File

@ -56,7 +56,7 @@ final class Env(
object Env {
lazy val current = "[boot] tv" describes new Env(
lazy val current = "tv" boot new Env(
config = lila.common.PlayApp loadConfig "tv",
db = lila.db.Env.current,
hub = lila.hub.Env.current,

View File

@ -82,7 +82,7 @@ final class Env(
object Env {
lazy val current: Env = "[boot] user" describes new Env(
lazy val current: Env = "user" boot new Env(
config = lila.common.PlayApp loadConfig "user",
db = lila.db.Env.current,
mongoCache = lila.memo.Env.current.mongoCache,

View File

@ -54,7 +54,7 @@ final class Env(
object Env {
lazy val current: Env = "[boot] video" describes new Env(
lazy val current: Env = "video" boot new Env(
config = lila.common.PlayApp loadConfig "video",
scheduler = lila.common.PlayApp.scheduler,
isDev = lila.common.PlayApp.isDev,

View File

@ -27,7 +27,7 @@ final class Env(config: Config, db: lila.db.Env) {
object Env {
lazy val current = "[boot] wiki" describes new Env(
lazy val current = "wiki" boot new Env(
config = lila.common.PlayApp loadConfig "wiki",
db = lila.db.Env.current)
}

View File

@ -24,7 +24,7 @@ final class Env(
object Env {
lazy val current: Env = "[boot] worldMap" describes new Env(
lazy val current: Env = "worldMap" boot new Env(
system = lila.common.PlayApp.system,
config = lila.common.PlayApp loadConfig "worldMap")
}

View File

@ -103,10 +103,10 @@ object ApplicationBuild extends Build {
libraryDependencies ++= provided(play.api, RM, PRM)
)
lazy val simulation = project("simulation", Seq(
common, hub, socket, game, tv, round, setup)).settings(
libraryDependencies ++= provided(play.api, RM)
)
// lazy val simulation = project("simulation", Seq(
// common, hub, socket, game, tv, round, setup)).settings(
// libraryDependencies ++= provided(play.api, RM)
// )
lazy val common = project("common").settings(
libraryDependencies ++= provided(play.api, play.test, RM)