Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## Unreleased

- Python server: Fix logging mechanism ([#820](https://github.com/mozilla/glean_parser/pull/820))

## 18.1.0

- Python server: Support sending custom pings without events ([#817](https://github.com/mozilla/glean_parser/pull/817))
Expand Down
5 changes: 3 additions & 2 deletions glean_parser/templates/python_server.jinja2
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ from datetime import datetime, timezone
from typing import Any
from uuid import uuid4
import json
import sys

GLEAN_EVENT_MOZLOG_TYPE = "glean-server-event"

Expand Down Expand Up @@ -111,7 +112,7 @@ class {{ ping|camelize }}ServerEventLogger:
}
ping_envelope_serialized = json.dumps(ping_envelope)

print(ping_envelope_serialized)
sys.stdout.write(f"{ping_envelope_serialized}\n")

{% for event in metrics_by_type["event"] %}
def {{ event|record_event_function_name }}(
Expand All @@ -132,7 +133,7 @@ class {{ ping|camelize }}ServerEventLogger:
"""
Record and submit a {{ event.category }}_{{ event.name }} event:
{{ event.description|clean_string }}
Event is logged to STDOUT via `print`.
Event is logged to STDOUT via `sys.stdout.write`.

:param str user_agent: The user agent.
:param str ip_address: The IP address. Will be used to decode Geo information
Expand Down