Add barebone logging interface
@anoe I didn't have time to do the investigation for #258 (closed), but in order to understand what's going on I will need debug logs, and commenting and uncommenting the same old printDebug
is tedious and error prone.
For this reason I have added a barebone logging interface which lives over at Gargantext.System.Logging
. Currently this uses the existing logging library Gargantext is using (yes, believe it or not we were creating a logger in the Env
, but never using it!) called fast-logger
, but the interface should make easier to replace this with another logging library once we made our mind on #229.
Therefore, this MR simply adds the interface and puts it into use inside addToCorpusWithQuery
, but adding a bunch of debug logs. Example:
addToCorpusWithQuery :: (FlowCmdM env err m, MonadJobStatus m)
=> User
-> CorpusId
-> WithQuery
-> Maybe API.Limit
-> JobHandle m
-> m ()
addToCorpusWithQuery user cid (WithQuery { _wq_query = q
, _wq_databases = dbs
, _wq_datafield = datafield
, _wq_lang = l
, _wq_flowListWith = flw }) maybeLimit jobHandle = do
-- LOGS EMITTED HERE!
logM DEBUG $ T.pack $ "[addToCorpusWithQuery] (cid, dbs) " <> show (cid, dbs)
logM DEBUG $ T.pack $ "[addToCorpusWithQuery] datafield " <> show datafield
logM DEBUG $ T.pack $ "[addToCorpusWithQuery] flowListWith " <> show flw
addLanguageToCorpus cid l
...
The advantage of this approach is that the logger interface exploits the running mode, which means that if we run the server in Dev
mode, we are going to see ALL logs, including the debug logs like this one:
However, if we run the server in Prod
mode, DEBUG logs won't be printed:
@cgenie You might want to know that this logging interface now exists. As said, is not meant to be a definitive logging interface, but more like a stepping stone towards #229, so that once we decide to swap library, we don't have to leak the concrete logger implementation everywhere.
Once I'm back from holidays I will keep investigating #258 (closed), but this MR can be merged independently as it's useful for debugging purposes.