Skip to content

Commit 12f2665

Browse files
committed
logging: update MozLogFormatter to output MozLog (bug 1977738) r=sheehan,zeid
There are two MozLog standards 1. https://wiki.mozilla.org/Firefox/Services/Logging#MozLog_application_logging_standard 2. https://firefox-source-docs.mozilla.org/mozbase/mozlog.html#data-format Up to now, lando was outputing the former, but this wasn't formatted very nicely in the GCP Log Explorer. Instead, modifying the `MozLogFormatter` to output data in a format compatible with the latter works much better. For the time being, the originally-formatted data is retained, as it doesn't impact the formatting in the Logs Explorer. --- * logging: update MozLogFormatter to output MozLog (bug 1977738) * landing_worker: fix log message typo * worker: log Worker.name when paused * dockerflow: log heartbeat requests at debug level Pull request: #834
1 parent 8a37d83 commit 12f2665

File tree

5 files changed

+19
-4
lines changed

5 files changed

+19
-4
lines changed

src/lando/api/legacy/workers/base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ def _start(self, max_loops: int | None = None, *args, **kwargs):
180180
while self._paused:
181181
# Wait a set number of seconds before checking paused variable again.
182182
logger.info(
183-
f"Paused, waiting {self.worker_instance.sleep_seconds} seconds..."
183+
f"{self.worker_instance.name} paused, waiting {self.worker_instance.sleep_seconds} seconds..."
184184
)
185185
self.throttle(self.worker_instance.sleep_seconds)
186186
self.loop(*args, **kwargs)

src/lando/api/legacy/workers/landing_worker.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -566,5 +566,5 @@ def bootstrap_repos(self):
566566
except Exception as exc:
567567
sentry_sdk.capture_exception(exc)
568568
logger.warning(
569-
f"Unexpected error `running mach` bootstrap for repo {repo.name}: {exc}"
569+
f"Unexpected error running `mach bootstrap` for repo {repo.name}: {exc}"
570570
)

src/lando/dockerflow/decorators.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def _wrapped_view(self, request, *args, **kwargs): # noqa: ANN001
2222
"t": int(1000 * (end_time - start_time)),
2323
}
2424

25-
request_logger.info("Request Summary: ", extra=summary)
25+
request_logger.debug("Request Summary: ", extra=summary)
2626

2727
return response
2828

src/lando/main/logging.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,17 @@ def format(self, record: logging.LogRecord) -> str:
7070
# (for example, the WSGIRequest object representing the request). Therefore
7171
# those values are converted to a string to avoid any issues when serializing.
7272
mozlog_record = {
73+
# MozLog https://firefox-source-docs.mozilla.org/mozbase/mozlog.html#data-format
74+
"action": "log",
75+
"time": int(record.created * 1e3),
76+
# We're single-threaded, but might as well report something useful.
77+
"thread": self.hostname,
78+
"pid": record.process,
79+
"source": record.name,
80+
# log action
81+
"level": record.levelname,
82+
"message": record.getMessage(),
83+
# Old format
7384
"EnvVersion": self.MOZLOG_ENVVERSION,
7485
"Hostname": self.hostname,
7586
"Logger": self.mozlog_logger,

src/lando/remote_settings.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,11 @@
88
"BACKEND": "storages.backends.gcloud.GoogleCloudStorage",
99
},
1010
}
11-
STATIC_URL = os.getenv("STATIC_URL")
11+
12+
# If missing, we default to `STATIC_URL`, from the `from settings import *`.
13+
# This allows the code to run in a local environment configured to simulate a remote
14+
# environment.
15+
STATIC_URL = os.getenv("STATIC_URL", STATIC_URL) # noqa: F405
1216
GS_BUCKET_NAME = os.getenv("GS_BUCKET_NAME")
1317
GS_PROJECT_ID = os.getenv("GS_PROJECT_ID")
1418
GS_QUERYSTRING_AUTH = False

0 commit comments

Comments
 (0)