error logging: Simplify deployment data.

We no longer have intermediate constants of
`git_described` and `zulip_version_const`.

Instead, we make a `deployment_data` dictionary
that is grep-friendly, and we just let
`deployment_repr` do simple formatting
without translating string constants.

This is pretty easy to test:

    - set DEBUG_ERROR_REPORTING = True
    - modify some code to throw an exception
    - see error output in #errors
    - use "/emails" with text-only option to view
      errors
This commit is contained in:
Steve Howell 2020-05-06 22:20:16 +00:00 committed by Tim Abbott
parent 710e3144e7
commit ebb16e7a68
2 changed files with 6 additions and 7 deletions

View File

@ -33,11 +33,8 @@ def user_info_str(report: Dict[str, Any]) -> str:
def deployment_repr(report: Dict[str, Any]) -> str:
deployment = 'Deployed code:\n'
for (label, field) in [('git', 'git_described'),
('ZULIP_VERSION', 'zulip_version_const'),
]:
if report[field] is not None:
deployment += '- %s: %s\n' % (label, report[field])
for field, val in report['deployment_data'].items():
deployment += '- %s: %s\n' % (field, val)
return deployment
def notify_browser_error(report: Dict[str, Any]) -> None:

View File

@ -26,8 +26,10 @@ def try_git_describe() -> Optional[str]:
return None
def add_deployment_metadata(report: Dict[str, Any]) -> None:
report['git_described'] = try_git_describe()
report['zulip_version_const'] = ZULIP_VERSION
report['deployment_data'] = dict(
git=try_git_describe(),
ZULIP_VERSION=ZULIP_VERSION,
)
def add_request_metadata(report: Dict[str, Any], request: HttpRequest) -> None:
report['has_request'] = True