From 39d493dfb7eb7404de2a4dd875d95eee943f954e Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Fri, 5 Oct 2018 21:41:56 +0200 Subject: [PATCH] Emit Settings on startup for debugging --- src/Application.hs | 5 +++-- src/Settings.hs | 18 ++++++++++++------ 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/src/Application.hs b/src/Application.hs index b15f11aab..e9a9dab00 100644 --- a/src/Application.hs +++ b/src/Application.hs @@ -114,9 +114,10 @@ makeFoundation appSettings@(AppSettings{..}) = do logFunc = messageLoggerSource tempFoundation appLogger flip runLoggingT logFunc $ do - smtpPool <- traverse createSmtpPool appSmtpConf - $logDebugS "InstanceID" $ UUID.toText appInstanceID + $logDebugS "Configuration" $ tshow appSettings + + smtpPool <- traverse createSmtpPool appSmtpConf -- Create the database connection pool sqlPool <- createPostgresqlPool diff --git a/src/Settings.hs b/src/Settings.hs index 2e3ac1eec..8ccdcf635 100644 --- a/src/Settings.hs +++ b/src/Settings.hs @@ -104,7 +104,7 @@ data AppSettings = AppSettings , appCryptoIDKeyFile :: FilePath , appInstanceIDFile :: Maybe FilePath - } + } deriving (Show) data UserDefaultConf = UserDefaultConf { userDefaultTheme :: Theme @@ -118,6 +118,9 @@ data PWHashConf = PWHashConf , pwHashStrength :: Int } +instance Show PWHashConf where + show PWHashConf{..} = "PWHashConf { pwHashStrength = " <> show pwHashStrength <> ", .. }" + instance FromJSON PWHashConf where parseJSON = withObject "PWHashConf" $ \o -> do pwHashAlgorithm' <- (o .: "algorithm" :: Aeson.Parser Text) @@ -209,11 +212,14 @@ deriveFromJSON } ''HaskellNet.AuthType -deriveFromJSON - defaultOptions - { fieldLabelModifier = intercalate "-" . map toLower . drop 1 . splitCamel - } - ''SmtpConf +instance FromJSON SmtpConf where + parseJSON = withObject "SmtpConf" $ \o -> do + smtpHost <- o .: "host" + smtpPort <- o .: "port" + smtpAuth <- assertM (not . null . smtpAuthUsername) <$> o .:? "auth" + smtpSsl <- o .: "ssl" + smtpPool <- o .: "pool" + return SmtpConf{..} deriveFromJSON defaultOptions