Skip to content

Commit

Permalink
Merge branch 'main' into remove-bg-footer-header
Browse files Browse the repository at this point in the history
  • Loading branch information
codemist authored Oct 30, 2024
2 parents 2eebca3 + b2df6a2 commit 6113f0b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 14 deletions.
15 changes: 8 additions & 7 deletions src/app/functions/server/glean.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@ import { v4 as uuidv4 } from "uuid";

const GLEAN_EVENT_MOZLOG_TYPE = "glean-server-event";

const loggingWinston = new LoggingWinston({
labels: {
name: GLEAN_EVENT_MOZLOG_TYPE,
version: "0.1.0",
},
});
const getLoggingWinston = () =>
new LoggingWinston({
labels: {
name: GLEAN_EVENT_MOZLOG_TYPE,
version: "0.1.0",
},
});

export function record(
category: string,
Expand All @@ -26,7 +27,7 @@ export function record(
// In GCP environments, use cloud logging instead of stdout.
// FIXME https://mozilla-hub.atlassian.net/browse/MNTOR-2401 - enable for stage and production
transports: ["gcpdev"].includes(process.env.APP_ENV ?? "local")
? [loggingWinston]
? [getLoggingWinston()]
: [new transports.Console()],
});

Expand Down
17 changes: 10 additions & 7 deletions src/app/functions/server/logging.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,22 @@
import { createLogger, transports } from "winston";
import { LoggingWinston } from "@google-cloud/logging-winston";

const loggingWinston = new LoggingWinston({
labels: {
name: "monitor-stats",
version: "0.1.0",
},
});
// Explicitly not run in tests (and other non-gcpdev environments)
/* c8 ignore next 7 */
const getLoggingWinston = () =>
new LoggingWinston({
labels: {
name: "monitor-stats",
version: "0.1.0",
},
});

export const logger = createLogger({
level: "info",
// In GCP environments, use cloud logging instead of stdout.
// FIXME https://mozilla-hub.atlassian.net/browse/MNTOR-2401 - enable for stage and production
/* c8 ignore next 3 - cannot test this outside of GCP currently */
transports: ["gcpdev"].includes(process.env.APP_ENV ?? "local")
? [loggingWinston]
? [getLoggingWinston()]
: [new transports.Console()],
});

0 comments on commit 6113f0b

Please sign in to comment.