aboutsummaryrefslogtreecommitdiff
path: root/src/executable/haskell/Service/AdListener.hs
diff options
context:
space:
mode:
Diffstat (limited to 'src/executable/haskell/Service/AdListener.hs')
-rw-r--r--src/executable/haskell/Service/AdListener.hs19
1 files changed, 6 insertions, 13 deletions
diff --git a/src/executable/haskell/Service/AdListener.hs b/src/executable/haskell/Service/AdListener.hs
index 9a9fc3d..b8ae5e9 100644
--- a/src/executable/haskell/Service/AdListener.hs
+++ b/src/executable/haskell/Service/AdListener.hs
@@ -3,8 +3,8 @@ module Service.AdListener
) where
import Control.Concurrent (threadDelay)
+import qualified Control.Logging as Logging
import qualified Data.Text as T
-import qualified Data.Text.IO as T
import qualified Data.Time.LocalTime as LocalTime
import Network.Wreq.Session (Session)
@@ -23,7 +23,7 @@ start :: Conf -> Session -> IO ()
start conf session = do
ads <- fetchAds conf session
let newURLs = map Ad.url ads
- T.putStrLn "Listening to new ads…"
+ Logging.log "Listening to new ads…"
sleepUntilReady conf
listenToNewAdsWithViewedURLs conf session newURLs
@@ -35,7 +35,7 @@ listenToNewAdsWithViewedURLs conf session viewedURLs = do
if not (null newAds)
then
do
- _ <- T.putStrLn (Ad.renderConsoleAds time newAds)
+ _ <- Logging.log (Ad.renderConsoleAds time newAds)
sendMail conf newAds
else
return ()
@@ -48,19 +48,12 @@ fetchAds conf session = do
ouestFranceAds <- FetchAd.ouestFrance session (Conf.ouestFranceUrls conf)
seLogerAds <- FetchAd.seLoger session (Conf.seLogerUrls conf)
let ads = leboncoinAds ++ ouestFranceAds ++ seLogerAds
- logFetchAds ads
- return ads
-
-logFetchAds :: [Ad] -> IO ()
-logFetchAds ads = do
- now <- TimeUtils.getCurrentFormattedTime
- T.putStrLn . T.concat $
- [ "At "
- , now
- , ": fetched "
+ Logging.log . T.concat $
+ [ "Fetched "
, T.pack . show $ length ads
, " ads"
]
+ return ads
sendMail :: Conf -> [Ad] -> IO ()
sendMail conf ads =