-
-
Notifications
You must be signed in to change notification settings - Fork 2
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
adding logging #74
Conversation
@@ -7,29 +7,29 @@ | |||
import uvicorn # pragma: no cover | |||
from fastapi import Request, FastAPI |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove lines 76-79
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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( |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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( |
There was a problem hiding this comment.
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)) |
There was a problem hiding this comment.
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( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
url
Codecov Report
@@ 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
Continue to review full report at Codecov.
|
Kudos, SonarCloud Quality Gate passed! 0 Bugs No Coverage information |
@rultor merge |
No description provided.