]> gitweb @ CieloNegro.org - Rakka.git/blobdiff - Rakka/SystemConfig.hs
Added basic logging facility: it needs a fix later
[Rakka.git] / Rakka / SystemConfig.hs
index 8a6be0283914eb5e78b35fee2ec88aec5244986e..58de2bec0ca22afb68ce1534dc23691617136cd1 100644 (file)
@@ -28,6 +28,9 @@ import           Subversion.FileSystem.Revision
 import           Subversion.FileSystem.Root
 import           Subversion.Repository
 import           System.FilePath.Posix
+import           System.Log.Logger
+
+logger = "Rakka.SystemConfig"
 
 
 data SystemConfig = SystemConfig {
@@ -72,20 +75,28 @@ getSysConf sc key
 
 getSysConf' :: SystemConfig -> SysConfValue -> IO SysConfValue
 getSysConf' sc key
-    = do fs    <- getRepositoryFS (scRepository sc)
+    = do let path = fromConfPath (sysConfPath key)
+
+         fs    <- getRepositoryFS (scRepository sc)
          rev   <- getYoungestRev fs
          value <- withRevision fs rev
-                  $ do let path = fromConfPath (sysConfPath key)
-                       exists <- isFile path
+                  $ do exists <- isFile path
                        case exists of
                          True
                              -> do str <- getFileContentsLBS path
                                    return $ Just $ chomp $ decodeLazy UTF8 str
                          False
                              -> return Nothing
+
          case value of
-           Just str -> return $ unmarshalSysConf key str
-           Nothing  -> sysConfDefault sc key
+           Just str
+               -> do let val = unmarshalSysConf key str
+                     debugM logger ("Got a config value at `" ++ path ++ "': " ++ show val)
+                     return val
+           Nothing
+               -> do val <- sysConfDefault sc key
+                     debugM logger ("Got no config value at `" ++ path ++ "'. Defaulting to " ++ show val)
+                     return val
 
 
 getSysConfA :: ArrowIO a => SystemConfig -> SysConfValue -> a b SysConfValue