]> gitweb.michael.orlitzky.com - dead/htsn.git/blobdiff - src/Configuration.hs
Disable syslog by default.
[dead/htsn.git] / src / Configuration.hs
index a9d5463f612885d4d831d04ee13db1dad6c67864..a90af38435cbcd3df1fefd767f401203a4bfa169 100644 (file)
@@ -10,13 +10,15 @@ where
 import System.Console.CmdArgs.Default ( Default(..) )
 import System.Log ( Priority( INFO ) )
 
-import qualified OptionalConfiguration as OC (OptionalConfiguration(..))
+import qualified OptionalConfiguration as OC (
+  OptionalConfiguration(..),
+  merge_maybes )
 import TSN.FeedHosts (FeedHosts(..))
 
 data Configuration =
   Configuration {
     feed_hosts       :: FeedHosts,
-    log_file         :: FilePath,
+    log_file         :: Maybe FilePath,
     log_level        :: Priority,
     password         :: String,
     output_directory :: FilePath,
@@ -27,7 +29,7 @@ data Configuration =
 -- | A Configuration with all of its fields set to their default
 --   values.
 instance Default Configuration where
-  def = Configuration def "htsn.log" INFO def "." True def
+  def = Configuration def def INFO def "." def def
 
 
 -- | Merge a Configuration with an OptionalConfiguration. This is more
@@ -39,13 +41,15 @@ merge_optional :: Configuration
 merge_optional cfg opt_cfg =
   Configuration
     all_feed_hosts
-    (merge (log_file cfg) (OC.log_file opt_cfg))
+    (OC.merge_maybes (log_file cfg) (OC.log_file opt_cfg))
     (merge (log_level cfg) (OC.log_level opt_cfg))
     (merge (password cfg) (OC.password opt_cfg))
     (merge (output_directory cfg) (OC.output_directory opt_cfg))
     (merge (syslog cfg) (OC.syslog opt_cfg))
     (merge (username cfg) (OC.username opt_cfg))
   where
+    -- | If the thing on the right is Just something, return that
+    --   something, otherwise return the thing on the left.
     merge :: a -> Maybe a -> a
     merge x Nothing  = x
     merge _ (Just y) = y