import Subversion.FileSystem.Root
import Subversion.Repository
import System.FilePath.Posix
+import System.Log.Logger
+
+logger = "Rakka.SystemConfig"
data SystemConfig = SystemConfig {
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