Skip to content

Conversation

@JaviCerveraIngram
Copy link
Collaborator

Add custom loggers to the automation classes, that automatically add relevant info of the request being processed. Legacy global logger still working in order to have a context-independent logger.

sformat = request.id + " " + request.contract.marketplace.id + base
[handler.setFormatter(logging.Formatter(sformat, "%I:%M:%S"))
for handler in self.__class__.logger.handlers]

Copy link
Contributor

Choose a reason for hiding this comment

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

Mb use the default setting for logger
Right now we use thrice this block. Only field sformat different

handlers = [copy.copy(hdlr) for hdlr in global_logger.handlers]
        log_level = global_logger.level
        self.__class__.logger.propagate = False
        self.__class__.logger.setLevel(log_level)
        [self.__class__.logger.addHandler(hdlr) for hdlr in handlers]
        base = " %(levelname)-6s; %(asctime)s; %(name)-6s; %(module)s:%(funcName)s:line" \
               "-%(lineno)d: %(message)s"
        sformat = request.id + "  " + request.contract.marketplace.id + base
        [handler.setFormatter(logging.Formatter(sformat, "%I:%M:%S"))
         for handler in self.__class__.logger.handlers]

Copy link
Contributor

Choose a reason for hiding this comment

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

Javi what you think about that suggestion?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Hasn't that been fixed in the commits made afterwards?

@codecov-io
Copy link

codecov-io commented Oct 3, 2019

Codecov Report

Merging #67 into master will decrease coverage by 0.07%.
The diff coverage is 90.41%.

Impacted file tree graph

@@            Coverage Diff            @@
##           master     #67      +/-   ##
=========================================
- Coverage   92.78%   92.7%   -0.08%     
=========================================
  Files          67      67              
  Lines        1872    1893      +21     
=========================================
+ Hits         1737    1755      +18     
- Misses        135     138       +3
Impacted Files Coverage Δ
connect/models/base.py 94.44% <ø> (ø) ⬆️
connect/resources/usage_file_automation.py 96.96% <100%> (+0.19%) ⬆️
connect/resources/base.py 94.5% <100%> (+0.12%) ⬆️
connect/resources/automation_engine.py 91.89% <100%> (-0.11%) ⬇️
connect/logger/logger.py 100% <100%> (+3.84%) ⬆️
connect/resources/fulfillment_automation.py 42.16% <54.54%> (+0.91%) ⬆️
connect/resources/tier_config_automation.py 88.67% <88.88%> (-3.33%) ⬇️
connect/resources/usage_automation.py 93.96% <90.9%> (+0.1%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 97fb781...0b652b8. Read the comment docs.

@vgrebenschikov vgrebenschikov merged commit efc1eea into cloudblue:master Oct 3, 2019
@JaviCerveraIngram JaviCerveraIngram deleted the CPS-43-logger-improvements branch October 4, 2019 12:20
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.

5 participants