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 logging #74

Merged
merged 5 commits into from
Feb 6, 2022
Merged

adding logging #74

merged 5 commits into from
Feb 6, 2022

Conversation

daniilBondarenk
Copy link
Contributor

No description provided.

@@ -7,29 +7,29 @@
import uvicorn # pragma: no cover
from fastapi import Request, FastAPI
Copy link
Owner

Choose a reason for hiding this comment

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

Add into file .gitignore new line

/.idea

https://stackoverflow.com/a/6313301/6916890

g2w/__main__.py Outdated
uvicorn.run(app, host="0.0.0.0", port=cmd.parse_args().port)
args = cmd.parse_args()
logger.setLevel(args.log.upper())
logger.debug('This message should go to the log file')
Copy link
Owner

Choose a reason for hiding this comment

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

Remove lines 76-79

Copy link
Owner

Choose a reason for hiding this comment

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

Regarding 0.0.0.0, please make a new cmd argument --host with default value 0.0.0.0 (non required)

g2w/api.py Outdated
@@ -4,6 +4,8 @@

from fastapi import Request, Response
from fastapi.routing import APIRoute
logger = logging.getLogger("uvicorn")
logger.setLevel(logging.DEBUG)
Copy link
Owner

Choose a reason for hiding this comment

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

Remove line 8 with setLevel

g2w/api.py Outdated
@@ -22,8 +24,8 @@ async def custom_route_handler(req: Request) -> Response:
resp.headers["X-Response-Time"] = str(duration)
# @todo #58/DEV Ensure that logging is enabled for HTTP traffic and
# could be used.
logging.debug("req duration: {0}", duration)
logging.debug(
logger.debug("req duration: {0}", duration)
Copy link
Owner

Choose a reason for hiding this comment

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

Replace {0} by %s

g2w/gitlab.py Outdated
from typing import List

import airspeed
from pydantic import BaseModel
logger = logging.getLogger("uvicorn")
logger.setLevel(logging.DEBUG)
Copy link
Owner

Choose a reason for hiding this comment

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

Remove .setLevel

@@ -57,6 +63,7 @@ def all_users(self) -> List[dict]:
"""
Fetch all users from worksection space.
"""
logger.debug("Fetching all users from worksection space.")
if not self.users:
# @todo #/DEV use memorize feature/approach instead of own caching.
self.users.extend(
Copy link
Owner

Choose a reason for hiding this comment

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

if ..
  ...

log.debug("Found %d worksection users", len(self.users))

g2w/ws.py Outdated
@@ -68,12 +75,14 @@ def add_comment(self, prj: int, task: int, body: str) -> dict:
"""
Add a comment to a particular worksection task id.
"""
logger.debug("Adding a comment: %s", body)
Copy link
Owner

Choose a reason for hiding this comment

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

url = sefl.post_comment_url(...)
log.debug("Add new comment by '%s' url based on text '%s'", url, body)
return post(url)

g2w/ws.py Outdated
return post(self.post_comment_url(prj, task, body))

def post_comment_url(self, prj, task, body) -> str:
"""
Construct URL for posting comments.
"""
logger.debug("Constructing post url")
return env("WS_URL_POST_COMMENT").format(
Copy link
Owner

Choose a reason for hiding this comment

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

url

g2w/ws.py Outdated
@@ -86,9 +95,11 @@ def add_task(self, prj, subj, body) -> dict:
"""
Add a ticket to a particular worksection project.
"""
logger.debug("Adding a ticket to a particular worksection project.")
return post(self.post_task_url(prj, subj, body))
Copy link
Owner

Choose a reason for hiding this comment

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

url

g2w/ws.py Outdated
return post(self.post_task_url(prj, subj, body))

def post_task_url(self, prj, subj, body) -> str:
logger.debug("Constructing task url")
return env("WS_URL_POST_TASK").format(
Copy link
Owner

Choose a reason for hiding this comment

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

url

@dgroup dgroup assigned dgroup and daniilBondarenk and unassigned dgroup Feb 6, 2022
@dgroup dgroup added this to the 0.3.0 milestone Feb 6, 2022
@codecov
Copy link

codecov bot commented Feb 6, 2022

Codecov Report

Merging #74 (c9af796) into master (2be2b45) will decrease coverage by 31.37%.
The diff coverage is 30.90%.

Impacted file tree graph

@@             Coverage Diff             @@
##           master      #74       +/-   ##
===========================================
- Coverage   92.62%   61.25%   -31.38%     
===========================================
  Files           7        7               
  Lines         122      160       +38     
===========================================
- Hits          113       98       -15     
- Misses          9       62       +53     
Impacted Files Coverage Δ
g2w/gitlab.py 56.52% <11.76%> (-40.54%) ⬇️
g2w/ws.py 45.83% <14.28%> (-39.89%) ⬇️
g2w/api.py 72.22% <33.33%> (-27.78%) ⬇️
g2w/__main__.py 60.00% <50.00%> (-29.48%) ⬇️
g2w/grafana.py 93.75% <100.00%> (+3.75%) ⬆️

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 2be2b45...c9af796. Read the comment docs.

g2w/ws.py Outdated Show resolved Hide resolved
@sonarcloud
Copy link

sonarcloud bot commented Feb 6, 2022

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@dgroup
Copy link
Owner

dgroup commented Feb 6, 2022

@rultor merge

@rultor
Copy link
Collaborator

rultor commented Feb 6, 2022

@rultor merge

@dgroup OK, I'll try to merge now. You can check the progress of the merge here

@rultor
Copy link
Collaborator

rultor commented Feb 6, 2022

@rultor merge

@dgroup Done! FYI, the full log is here (took me 3min)

@dgroup dgroup merged commit 6a3c527 into dgroup:master Feb 6, 2022
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.

4 participants