Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding logger in global level. #191

Merged
merged 9 commits into from
Dec 20, 2023
Merged

Adding logger in global level. #191

merged 9 commits into from
Dec 20, 2023

Conversation

RubelMozumder
Copy link
Collaborator

@RubelMozumder RubelMozumder commented Dec 3, 2023

  1. Module level logger.
  2. Responsive for the nomad logger.
  3. No error anymore from missing fields but a log warning for those fields, groups, and attributes.

PR #175 is closed and fixed here.

@coveralls
Copy link

coveralls commented Dec 3, 2023

Pull Request Test Coverage Report for Build 7277551900

  • 33 of 37 (89.19%) changed or added relevant lines in 4 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.02%) to 44.55%

Changes Missing Coverage Covered Lines Changed/Added Lines %
pynxtools/dataconverter/convert.py 5 9 55.56%
Totals Coverage Status
Change from base Build 7264459327: 0.02%
Covered Lines: 4864
Relevant Lines: 10918

💛 - Coveralls

@RubelMozumder RubelMozumder marked this pull request as ready for review December 3, 2023 15:00
@RubelMozumder RubelMozumder requested a review from domna December 3, 2023 15:00
Copy link
Collaborator

@domna domna left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two points:

  • I would rather not pass the logging to each function as parameter but use the central logger
  • What is the rational behind removing the UNDOCUMENTED level? I think it's not too important to have this but generally I think it's nice to have them distinguishable.

pynxtools/dataconverter/convert.py Outdated Show resolved Hide resolved
pynxtools/dataconverter/convert.py Show resolved Hide resolved
@RubelMozumder
Copy link
Collaborator Author

Two points:

  • I would rather not pass the logging to each function as parameter but use the central logger
  • What is the rational behind removing the UNDOCUMENTED level? I think it's not too important to have this but generally I think it's nice to have them distinguishable.

I ran the XRD reader in nomad with and without passing nomad logger in convert, I got the following results:

  1. As I said if we need to get log data in another process or platform, we must pass the corresponding logger from that process or platform.
  2. Nomad logger does not support string format with % opt., but support `f-string, I think which is the modern way (especially after python-3.6) to write a variable passed string.

I would say we should use f-string as the logger message and we must pass the logger as a parameter in the function if we want users to get the pynxtools log data in nomad.

Here, I added two pics with and without passing the logger from nomad.

With_logger_passing_from_nomad
Without_nomad_logger

If you follow the last PR that was #175, I had the similar opinion.

@domna
Copy link
Collaborator

domna commented Dec 4, 2023

I ran the XRD reader in nomad with and without passing nomad logger in convert, I got the following results:

  1. As I said if we need to get log data in another process or platform, we must pass the corresponding logger from that process or platform.

I had a look at how nomad is integrating this to see if we'd need to use some prefix to let the logs show up. I found, however, that the get_logger function wraps this to convert this to a structured log (with time, parser etc.). So you are right, we cannot just use logging and have to pass the logger.

  1. Nomad logger does not support string format with % opt., but support `f-string, I think which is the modern way (especially after python-3.6) to write a variable passed string.

Yes, I think we talked about this already. We can just go to the f-string formatting. One note: For logging it's normally recommended due to the lazy evaluation with the % syntax (i.e., if the log is not displayed the code is not run). In reality this will however not really make I difference I guess.

Copy link
Collaborator

@domna domna left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@domna domna force-pushed the mpesworkshop_167_new branch from 70212da to 0bdb8fe Compare December 19, 2023 19:18
@RubelMozumder RubelMozumder merged commit c4d1b9c into master Dec 20, 2023
5 checks passed
@RubelMozumder RubelMozumder deleted the mpesworkshop_167_new branch May 31, 2024 13:40
@RubelMozumder RubelMozumder restored the mpesworkshop_167_new branch May 31, 2024 13:41
@RubelMozumder RubelMozumder deleted the mpesworkshop_167_new branch June 4, 2024 09:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants