-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #96 from xtrojak/92-streaming-log
Store logs during annotation
- Loading branch information
Showing
18 changed files
with
192 additions
and
154 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,7 @@ | ||
**__pycache__ | ||
MSMetaEnhancer_*.log | ||
.pytest_cache | ||
.coverage | ||
dist | ||
MSMetaEnhancer.egg-info | ||
.vscode |
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
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
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
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
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
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
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
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
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
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,35 @@ | ||
from MSMetaEnhancer.libs.utils.Job import Job | ||
|
||
|
||
class LogRecord: | ||
def __init__(self, metadata): | ||
self.metadata = metadata | ||
self.logs = [] | ||
|
||
def format_log(self, level: str) -> str: | ||
"""Format log message according to level. | ||
Args: | ||
level (str): Log level to use for formatting. | ||
Returns: | ||
str: Formatted log message | ||
""" | ||
message = f'Issues related to metadata:\n\n{self.metadata}\n\n' | ||
filtered_logs = [log['msg'] for log in self.logs if level >= log['level']] | ||
if filtered_logs: | ||
for log in filtered_logs: | ||
message += f'{log}\n' | ||
else: | ||
return None | ||
return f'{message}\n' | ||
|
||
def update(self, exc: Exception, job: Job, level: str): | ||
""" | ||
Process given log record. | ||
:param exc: exception | ||
:param job: related job | ||
:param level: log level | ||
""" | ||
self.logs.append({'level': level, 'msg': f'-> {type(exc).__name__} - {job}:\n{exc}'}) |
Oops, something went wrong.