Skip to content

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
    • Help
    • Submit feedback
    • Contribute to GitLab
  • Sign in
haskell-gargantext
haskell-gargantext
  • Project
    • Project
    • Details
    • Activity
    • Releases
    • Cycle Analytics
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Charts
  • Issues 154
    • Issues 154
    • List
    • Board
    • Labels
    • Milestones
  • Merge Requests 7
    • Merge Requests 7
  • CI / CD
    • CI / CD
    • Pipelines
    • Jobs
    • Schedules
    • Charts
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Members
    • Members
  • Collapse sidebar
  • Activity
  • Graph
  • Charts
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
  • gargantext
  • haskell-gargantexthaskell-gargantext
  • Merge Requests
  • !192

Merged
Opened Jul 28, 2023 by Alfredo Di Napoli@AlfredoDiNapoli
  • Report abuse
Report abuse

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:

Screenshot_2023-07-28_at_10.51.15

However, if we run the server in Prod mode, DEBUG logs won't be printed:

Screenshot_2023-07-28_at_10.51.02

@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.

Check out, review, and merge locally

Step 1. Fetch and check out the branch for this merge request

git fetch origin
git checkout -b adinapoli/issue-258 origin/adinapoli/issue-258

Step 2. Review the changes locally

Step 3. Merge the branch and fix any conflicts that come up

git fetch origin
git checkout origin/dev
git merge --no-ff adinapoli/issue-258

Step 4. Push the result of the merge to GitLab

git push origin dev

Note that pushing to GitLab requires write access to this repository.

Tip: You can also checkout merge requests locally by following these guidelines.

  • Discussion 4
  • Commits 5
  • Pipelines 5
  • Changes 10
Assignee
Assign to
None
Milestone
None
Assign milestone
Time tracking
0
Labels
None
Assign labels
  • View project labels
Reference: gargantext/haskell-gargantext!192

Revert this merge request

This will create a new commit in order to revert the existing changes.

Switch branch
Cancel
A new branch will be created in your fork and a new merge request will be started.

Cherry-pick this merge request

Switch branch
Cancel
A new branch will be created in your fork and a new merge request will be started.