-
Notifications
You must be signed in to change notification settings - Fork 219
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
Add Slack functionality inside logger #2395
Conversation
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.
Thanks so much for your contribution @Kerfred! This PR just needs a few small changes then it should be ready 🙂
@@ -61,14 +61,17 @@ def _message(text: str, summary: str = None, level: Level = Level.INFO) -> None: | |||
|
|||
|
|||
def verbose(text: str, summary: str = None) -> None: | |||
log.debug(text) |
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.
This (and all other log
calls in made by this PR) should have stacklevel=2
added to them:
log.debug(text) | |
log.debug(text, stacklevel=2) |
This will ensure that when a log line is emitted from this module, it appears in the logs as if it came from the place where slack.verbose
(or the other logging functions) were called. So rather than something like
DEBUG slack.py:63 - <the real message>
it'd say something like
DEBUG - indexer.py:102 - <the real message>
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.
OK
I have added stacklevel=2, commited and pushed again on the branch. |
As I was testing this, I realized that because we're calling diff --git a/ingestion_server/ingestion_server/slack.py b/ingestion_server/ingestion_server/slack.py
index 717f5dbda..f5246f353 100644
--- a/ingestion_server/ingestion_server/slack.py
+++ b/ingestion_server/ingestion_server/slack.py
@@ -65,8 +65,8 @@ def verbose(text: str, summary: str = None) -> None:
_message(text, summary, level=Level.VERBOSE)
-def info(text: str, summary: str = None) -> None:
- log.info(text, stacklevel=2)
+def info(text: str, summary: str = None, stacklevel: int = 2) -> None:
+ log.info(text, stacklevel=stacklevel)
_message(text, summary, level=Level.INFO)
@@ -82,4 +82,4 @@ def status(model: str, text: str) -> None:
Model is required an all messages get prepended with the model.
"""
text = f"`{model}`: {text}"
- info(text, None)
+ info(text, None, stacklevel=3) What do you think? |
Add stacklevel as an argument of the methods verbose(), info() and error()
You are totally right. I have done the change. |
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.
Thanks for this @Kerfred! This looks great.
Based on the low urgency of this PR, the following reviewers are being gently reminded to review this PR: @krysal Excluding weekend1 days, this PR was ready for review 7 day(s) ago. PRs labelled with low urgency are expected to be reviewed within 5 weekday(s)2. @Kerfred, if this PR is not ready for a review, please draft it to prevent reviewers from getting further unnecessary pings. Footnotes
|
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.
Tested this all locally and it worked perfectly! This is such an improvement, thanks a ton @Kerfred 😄
Fixes
Fixes #698 by @dhruvkb
Description
The slack logger is now handling the standard logging. Nomore need to add log.info(), log.error(), log.debug() when we are logging to slack.
Checklist
Update index.md
).main
) or a parent feature branch.Developer Certificate of Origin
Developer Certificate of Origin