-
Notifications
You must be signed in to change notification settings - Fork 12
Added tenenat key to log #56
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
base: formsflow-merge
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| """Module handle the console display formatting.""" | ||
| import logging | ||
| from redash import settings | ||
|
|
||
| class CustomFormatter(logging.Formatter): | ||
| """Class extends the logging Formatter class to support custom colour messages.""" | ||
|
|
||
| blue = "\x1b[34;21m" | ||
| grey = "\x1b[38;21m" | ||
| green = "\x1b[32;1m" | ||
| yellow = "\x1b[33;21m" | ||
| red = "\x1b[31;21m" | ||
| bold_red = "\x1b[31;1m" | ||
| reset = "\x1b[0m" | ||
| __format = ( | ||
| "%(org_id)s - %(asctime)s - %(name)s - %(levelname)s - %(message)s (%(filename)s:%(lineno)d)" | ||
| ) | ||
|
|
||
| FORMATS = { | ||
| logging.DEBUG: blue + __format + reset, | ||
| logging.INFO: green + __format + reset, | ||
| logging.WARNING: yellow + __format + reset, | ||
| logging.ERROR: red + __format + reset, | ||
| logging.CRITICAL: bold_red + __format + reset, | ||
| } | ||
|
|
||
|
|
||
| org_id = "default" | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It might be better to change this from a Class variable to an Instance Variables |
||
|
|
||
| def format(self, record): | ||
| """Returns the formatted information.""" | ||
| log_fmt = self.FORMATS.get(record.levelno) | ||
| formatter = logging.Formatter(log_fmt) | ||
|
|
||
| record.org_id = CustomFormatter.org_id | ||
| return formatter.format(record) | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
|
|
||
| import logging | ||
| from rq import get_current_job | ||
|
|
||
| class CurrentJobFilter(logging.Filter): | ||
| org_id = "default" | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It might be better to change this from a Class variable to an Instance Variables |
||
| def filter(self, record): | ||
| current_job = get_current_job() | ||
|
|
||
| record.job_id = current_job.id if current_job else "" | ||
| record.job_func_name = current_job.func_name if current_job else "" | ||
| # record.org_id = _get_current_org() | ||
| record.org_id = CurrentJobFilter.org_id | ||
| return True | ||
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.
Settings is being imported but not used.