Yi EungJun 2014-07-23
config: Allow to customize application-logger.xml
Problem: Customizing application-logger.xml was quite difficult because the file
may be overwritten by updating Yobi.

Solution:
* Rename conf/application-logger.xml to
  conf/application-logger.xml.default not to overwrite user's file.
* Generate conf/application-logger.xml if it doesn't exist by copying from
  conf/application-logger.xml.default when Yobi starts.
@66e92244535f6d0f1942ec1cf00e7189e151d154
conf/application-logger.xml.default (Renamed from conf/application-logger.xml)
--- conf/application-logger.xml
+++ conf/application-logger.xml.default
No changes
project/Build.scala
--- project/Build.scala
+++ project/Build.scala
@@ -7,6 +7,7 @@
 import play.Project.lessEntryPoints
 import java.nio.file.Files
 import java.nio.file.Paths
+import java.nio.file.Path
 import java.io.IOException;
 import com.typesafe.config._
 
@@ -15,6 +16,8 @@
   val appName         = "yobi"
   val APPLICATION_CONF_DEFAULT = "application.conf.default"
   val APPLICATION_CONF = "application.conf"
+  val LOG_CONF_DEFAULT = "application-logger.xml.default"
+  val LOG_CONF = "application-logger.xml"
   val VERSION_CONF = "version.conf"
   val CONFIG_DIRNAME = "conf"
 
@@ -68,9 +71,9 @@
 
   def basePath = new File(System.getProperty("user.dir")).getAbsolutePath()
 
-  val initConfig = {
-    val pathToDefaultConfig = Paths.get(basePath, CONFIG_DIRNAME, APPLICATION_CONF_DEFAULT)
-    val pathToConfig = Paths.get(basePath, CONFIG_DIRNAME, APPLICATION_CONF)
+  def configDirPath = basePath + "/" + CONFIG_DIRNAME
+
+  def initConfig(pathToDefaultConfig: Path, pathToConfig: Path): Unit = {
     val configFile = pathToConfig.toFile()
 
     if (!configFile.exists()) {
@@ -86,6 +89,15 @@
     }
   }
 
+  def initConfig: Unit = {
+    initConfig(
+      Paths.get(configDirPath, APPLICATION_CONF_DEFAULT),
+      Paths.get(configDirPath, APPLICATION_CONF))
+    initConfig(
+      Paths.get(configDirPath, LOG_CONF_DEFAULT),
+      Paths.get(configDirPath, LOG_CONF))
+  }
+
   val main = {
     initConfig
 
Add a comment
List