I have searched for a clear answer to this question but haven't been able to find one yet - How do I enable automatic logging of SQL statements being executed by persistent? Can someone give me a small example program for this?
Following is an example program that currently does not have logging. How do I enable logging in it?
share [mkPersist sqlSettings, mkMigrate "migrateAll"] [persistLowerCase|
Person
name Text
status Text Maybe
deriving Show
|]
main :: IO ()
main = runSqlite ":memory:" $ do
runMigration migrateAll
insert (Person "Oliver Charles" Nothing)
insert (Person "Jon Snow" Nothing)
insert (Person "Marky Mark" (Just "helloo helloo"))
noStatusPeople >>= mapM_ (liftIO . print)
where
noStatusPeople =
select $ from $ \person -> do
where_ (person ^. PersonStatus ==. val Nothing)
return (person ^. PersonName)