Açıklama Yok
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

functionslog.js 1.4KB

1234567891011121314151617181920212223242526272829303132333435
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. exports.logEntries = exports.getApiFilter = void 0;
  4. const logger_1 = require("../logger");
  5. function getApiFilter(functionList) {
  6. const baseFilter = 'resource.type="cloud_function" OR ' +
  7. '(resource.type="cloud_run_revision" AND ' +
  8. 'labels."goog-managed-by"="cloudfunctions")';
  9. if (functionList) {
  10. const apiFuncFilters = functionList.split(",").map((fn) => {
  11. return `resource.labels.function_name="${fn}" ` + `OR resource.labels.service_name="${fn}"`;
  12. });
  13. return baseFilter + `\n(${apiFuncFilters.join(" OR ")})`;
  14. }
  15. return baseFilter;
  16. }
  17. exports.getApiFilter = getApiFilter;
  18. function logEntries(entries) {
  19. if (!entries || entries.length === 0) {
  20. logger_1.logger.info("No log entries found.");
  21. return;
  22. }
  23. for (let i = entries.length - 1; i >= 0; i--) {
  24. const entry = entries[i];
  25. const timestamp = entry.timestamp || "---";
  26. const severity = (entry.severity || "?").substring(0, 1);
  27. const name = entry.resource.labels.function_name || entry.resource.labels.service_name;
  28. const message = entry.textPayload ||
  29. JSON.stringify(entry.jsonPayload) ||
  30. JSON.stringify(entry.protoPayload) ||
  31. "";
  32. logger_1.logger.info(`${timestamp} ${severity} ${name}: ${message}`);
  33. }
  34. }
  35. exports.logEntries = logEntries;