diff --git a/python/humbug/report.py b/python/humbug/report.py index 183435b..8dd5a07 100644 --- a/python/humbug/report.py +++ b/python/humbug/report.py @@ -18,6 +18,7 @@ import uuid import requests +from bugout.app import Bugout from .consent import HumbugConsent from .system_information import ( @@ -46,8 +47,7 @@ class Modes(Enum): DEFAULT = 0 SYNCHRONOUS = 1 - -class Reporter: +class HumbugReporter: def __init__( self, name: str, @@ -87,7 +87,7 @@ def __init__( self.is_excepthook_set = False self.is_loggerhook_set = False - + def wait(self) -> None: concurrent.futures.wait( self.report_futures, timeout=float(self.timeout_seconds) @@ -113,7 +113,7 @@ def system_tags(self) -> List[str]: tags.append("client:{}".format(self.client_id)) return tags - + def publish(self, report: Report, wait: bool = False) -> None: if not self.consent.check(): return @@ -414,3 +414,38 @@ def showtraceback(*args, **kwargs): ipython_shell.showtraceback = showtraceback self.setup_excepthook(publish=True, tags=tags) + + +class Reporter(HumbugReporter): + + def publish(self, report: Report, wait: bool = False) -> None: + if not self.consent.check(): + return + if self.bugout_token is None or self.bugout_journal_id is None: + return + + try: + report.tags = list(set(report.tags)) + if wait or self.executor is None: + self.bugout.create_entry( + token=self.bugout_token, + journal_id=self.bugout_journal_id, + title=report.title, + content=report.content, + tags=report.tags, + timeout=self.timeout_seconds, + ) + else: + report_future = self.executor.submit( + self.bugout.create_entry, + token=self.bugout_token, + journal_id=self.bugout_journal_id, + title=report.title, + content=report.content, + tags=report.tags, + timeout=self.timeout_seconds, + ) + self.report_futures.append(report_future) + except: + pass + diff --git a/python/setup.py b/python/setup.py index 687a380..dd9654c 100644 --- a/python/setup.py +++ b/python/setup.py @@ -8,7 +8,7 @@ name="humbug", version="0.2.0", packages=find_packages(), - install_requires=["requests"], + install_requires=["requests","bugout"], extras_require={ "dev": ["black", "mypy", "wheel"], "distribute": ["setuptools", "twine", "wheel"],