sosia-dev / sosia

Sosia: Automatic author matching in Scopus on-line
https://sosia.readthedocs.io/
MIT License
11 stars 3 forks source link

#14 Logging #42

Closed nils-herrmann closed 2 weeks ago

nils-herrmann commented 1 month ago

New PR to avoid confusion due to merge conflicts and commit reversions.

Log all queries made withScopusSearch() and AuthorSearch() at DEBUG level in ~/.cache/sosia/sosia.log

codeclimate[bot] commented 1 month ago

Code Climate has analyzed commit d32ed0bc and detected 1 issue on this pull request.

Here's the issue category breakdown:

Category Count
Complexity 1

View more on Code Climate.

Michael-E-Rose commented 1 month ago

That's a good start already. But we need to write it such that the file comes out fresh when I initiate a new Original(). Maybe we put the creation of the logfile in there, and move the log file connection around as private attribute?

And finally two requests on the stored information:

  1. We need to store the view of the request.
  2. As some queries can become very long (the max query string length is 255 characters), I think it's better to have it a separate line.
  3. Maybe we can log each query like so: Timestamp, Scopus API (or pybliometrics class used) and view, query, length of results. Each of these information on a separate line, ended by newline.
nils-herrmann commented 3 weeks ago

The LOG_FILE.log now has entries like:

24-11-05 21:04:40 - DEBUG: 
    - Scopus class: AuthorSearch
    - View: STANDARD
    - Query: AU-ID(53164702100)
    - Nr Results: 1
24-11-05 21:04:41 - DEBUG: 
    - Scopus class: ScopusSearch
    - View: COMPLETE
    - Query: REF(55208373700 OR 55208373700) AND PUBYEAR BEF 2017 AND NOT AU-ID(55208373700) AND NOT AU-ID(55208373700)
    - Nr Results: 0
24-11-05 21:04:42 - DEBUG: 
    - Scopus class: ScopusSearch
    - View: COMPLETE
    - Query: REF(2-s2.0-84959420483 OR 2-s2.0-84949113230) AND PUBYEAR BEF 2017 AND NOT AU-ID(55208373700) AND NOT AU-ID(55208373700)
    - Nr Results: 0
Michael-E-Rose commented 3 weeks ago

Yeah, that looks great! Let's just change some words here and then we're done:

nils-herrmann commented 3 weeks ago

A log entry now looks like this:

24-11-11 09:59:52 - DEBUG: 
    - Scopus API: Scopus Search
    - View: COMPLETE
    - Query: SOURCE-ID(14204) AND PUBYEAR IS 1984
    - Results: 730
Michael-E-Rose commented 2 weeks ago

Last request: Can you please move all the new functions from sosia/utils/logger.py to sosia/establishing/logger.py? (And then remove the new utils folder again.)

nils-herrmann commented 2 weeks ago

I moved the file to the establishing folder (and changed the corresponding imports).

What do you mean by this?

(And then remove the new utils folder again.)

Michael-E-Rose commented 2 weeks ago

What do you mean by this?

(And then remove the new utils folder again.)

You created a new utils folder. But you removed it already, so all is fine. Thanks, Nils!