-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added AppNameFilter to resolve app_name issue
- Loading branch information
Showing
2 changed files
with
39 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import logging | ||
|
||
class AppNameFilter(logging.Filter): | ||
"""Filter that adds an app_name attribute to log records.""" | ||
|
||
def __init__(self, app_name): | ||
"""Initialize the filter with an app name. | ||
Args: | ||
app_name (str): Name to be added to log records | ||
""" | ||
super().__init__() | ||
self.app_name = app_name | ||
|
||
def filter(self, record): | ||
"""Add app_name attribute to the record. | ||
Args: | ||
record (LogRecord): The log record to filter | ||
Returns: | ||
bool: Always returns True to allow the record through | ||
""" | ||
record.app_name = self.app_name | ||
return True |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters