-
Notifications
You must be signed in to change notification settings - Fork 326
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Refactor how we use loggers * cleanup leftovers * Improve tests
- Loading branch information
1 parent
6d528dc
commit d088ef3
Showing
18 changed files
with
156 additions
and
92 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
--- | ||
"products-feed": patch | ||
"klaviyo": patch | ||
"app-avatax": patch | ||
"cms-v2": patch | ||
"search": patch | ||
"smtp": patch | ||
--- | ||
|
||
Use new way of creating logger from `@saleor/apps-logger` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@saleor/apps-logger": minor | ||
--- | ||
|
||
Renamed exported `logger` to `rootLogger` so we avoid collision of names when using `logger` in monorepo. Also `createLogger` function has been removed in favour of app defining it in their codebase. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,22 @@ | ||
// eslint-disable-next-line no-restricted-imports | ||
import { attachLoggerConsoleTransport, createLogger, logger } from "@saleor/apps-logger"; | ||
import { attachLoggerConsoleTransport, rootLogger } from "@saleor/apps-logger"; | ||
import { attachLoggerOtelTransport } from "@saleor/apps-logger/node"; | ||
|
||
import packageJson from "../package.json"; | ||
import { loggerContext } from "../src/logger-context"; | ||
|
||
logger.settings.maskValuesOfKeys = ["username", "password", "token"]; | ||
rootLogger.settings.maskValuesOfKeys = ["username", "password", "token"]; | ||
|
||
if (process.env.ENABLE_MIGRATION_CONSOLE_LOGGER === "true") { | ||
attachLoggerConsoleTransport(logger); | ||
attachLoggerConsoleTransport(rootLogger); | ||
} | ||
|
||
attachLoggerOtelTransport(logger, packageJson.version, loggerContext); | ||
attachLoggerOtelTransport(rootLogger, packageJson.version, loggerContext); | ||
|
||
export { createLogger, logger }; | ||
export const createMigrationScriptLogger = (name: string, params?: Record<string, unknown>) => | ||
rootLogger.getSubLogger( | ||
{ | ||
name: name, | ||
}, | ||
params, | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,28 @@ | ||
import { attachLoggerConsoleTransport, createLogger, logger } from "@saleor/apps-logger"; | ||
import { attachLoggerConsoleTransport, rootLogger } from "@saleor/apps-logger"; | ||
|
||
import packageJson from "../package.json"; | ||
|
||
logger.settings.maskValuesOfKeys = ["metadata", "username", "password", "apiKey"]; | ||
rootLogger.settings.maskValuesOfKeys = ["metadata", "username", "password", "apiKey"]; | ||
|
||
if (process.env.NODE_ENV !== "production") { | ||
attachLoggerConsoleTransport(logger); | ||
attachLoggerConsoleTransport(rootLogger); | ||
} | ||
|
||
if (typeof window === "undefined") { | ||
import("@saleor/apps-logger/node").then( | ||
async ({ attachLoggerOtelTransport, attachLoggerSentryTransport, LoggerContext }) => { | ||
const loggerContext = await import("./logger-context").then((m) => m.loggerContext); | ||
|
||
attachLoggerSentryTransport(logger); | ||
attachLoggerOtelTransport(logger, packageJson.version, loggerContext); | ||
attachLoggerSentryTransport(rootLogger); | ||
attachLoggerOtelTransport(rootLogger, packageJson.version, loggerContext); | ||
}, | ||
); | ||
} | ||
|
||
export { createLogger, logger }; | ||
export const createLogger = (name: string, params?: Record<string, unknown>) => | ||
rootLogger.getSubLogger( | ||
{ | ||
name: name, | ||
}, | ||
params, | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 3 additions & 3 deletions
6
apps/cms-v2/src/modules/providers/payloadcms/payloadcms-bulk-sync-processor.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,28 @@ | ||
import { attachLoggerConsoleTransport, createLogger, logger } from "@saleor/apps-logger"; | ||
import { attachLoggerConsoleTransport, rootLogger } from "@saleor/apps-logger"; | ||
|
||
import packageJson from "../package.json"; | ||
|
||
logger.settings.maskValuesOfKeys = ["metadata", "username", "password", "apiKey"]; | ||
rootLogger.settings.maskValuesOfKeys = ["metadata", "username", "password", "apiKey"]; | ||
|
||
if (process.env.NODE_ENV !== "production") { | ||
attachLoggerConsoleTransport(logger); | ||
attachLoggerConsoleTransport(rootLogger); | ||
} | ||
|
||
if (typeof window === "undefined") { | ||
import("@saleor/apps-logger/node").then( | ||
async ({ attachLoggerOtelTransport, attachLoggerSentryTransport }) => { | ||
const loggerContext = await import("./logger-context").then((m) => m.loggerContext); | ||
|
||
attachLoggerSentryTransport(logger); | ||
attachLoggerOtelTransport(logger, packageJson.version, loggerContext); | ||
attachLoggerSentryTransport(rootLogger); | ||
attachLoggerOtelTransport(rootLogger, packageJson.version, loggerContext); | ||
}, | ||
); | ||
} | ||
|
||
export { createLogger, logger }; | ||
export const createLogger = (name: string, params?: Record<string, unknown>) => | ||
rootLogger.getSubLogger( | ||
{ | ||
name: name, | ||
}, | ||
params, | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,28 @@ | ||
import { attachLoggerConsoleTransport, createLogger, logger } from "@saleor/apps-logger"; | ||
import { attachLoggerConsoleTransport, rootLogger } from "@saleor/apps-logger"; | ||
|
||
import packageJson from "../package.json"; | ||
|
||
logger.settings.maskValuesOfKeys = ["metadata", "username", "password", "apiKey"]; | ||
rootLogger.settings.maskValuesOfKeys = ["metadata", "username", "password", "apiKey"]; | ||
|
||
if (process.env.NODE_ENV !== "production") { | ||
attachLoggerConsoleTransport(logger); | ||
attachLoggerConsoleTransport(rootLogger); | ||
} | ||
|
||
if (typeof window === "undefined") { | ||
import("@saleor/apps-logger/node").then( | ||
async ({ attachLoggerOtelTransport, attachLoggerSentryTransport, LoggerContext }) => { | ||
async ({ attachLoggerOtelTransport, attachLoggerSentryTransport }) => { | ||
const loggerContext = await import("./logger-context").then((m) => m.loggerContext); | ||
|
||
attachLoggerSentryTransport(logger); | ||
attachLoggerOtelTransport(logger, packageJson.version, loggerContext); | ||
attachLoggerSentryTransport(rootLogger); | ||
attachLoggerOtelTransport(rootLogger, packageJson.version, loggerContext); | ||
}, | ||
); | ||
} | ||
|
||
export { createLogger, logger }; | ||
export const createLogger = (name: string, params?: Record<string, unknown>) => | ||
rootLogger.getSubLogger( | ||
{ | ||
name: name, | ||
}, | ||
params, | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,27 @@ | ||
// eslint-disable-next-line no-restricted-imports | ||
import { attachLoggerConsoleTransport, createLogger, logger } from "@saleor/apps-logger"; | ||
import { attachLoggerConsoleTransport, rootLogger } from "@saleor/apps-logger"; | ||
|
||
import packageJson from "../../package.json"; | ||
|
||
logger.settings.maskValuesOfKeys = ["token", "secretKey"]; | ||
rootLogger.settings.maskValuesOfKeys = ["token", "secretKey"]; | ||
|
||
if (process.env.NODE_ENV !== "production") { | ||
attachLoggerConsoleTransport(logger); | ||
attachLoggerConsoleTransport(rootLogger); | ||
} | ||
|
||
if (typeof window === "undefined") { | ||
import("@saleor/apps-logger/node").then( | ||
({ attachLoggerOtelTransport, attachLoggerSentryTransport }) => { | ||
attachLoggerSentryTransport(logger); | ||
attachLoggerOtelTransport(logger, packageJson.version); | ||
attachLoggerSentryTransport(rootLogger); | ||
attachLoggerOtelTransport(rootLogger, packageJson.version); | ||
}, | ||
); | ||
} | ||
|
||
export { createLogger, logger }; | ||
export const createLogger = (name: string, params?: Record<string, unknown>) => | ||
rootLogger.getSubLogger( | ||
{ | ||
name: name, | ||
}, | ||
params, | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,28 @@ | ||
import { attachLoggerConsoleTransport, createLogger, logger } from "@saleor/apps-logger"; | ||
import { attachLoggerConsoleTransport, rootLogger } from "@saleor/apps-logger"; | ||
|
||
import packageJson from "../package.json"; | ||
|
||
logger.settings.maskValuesOfKeys = ["metadata", "username", "password", "apiKey"]; | ||
rootLogger.settings.maskValuesOfKeys = ["metadata", "username", "password", "apiKey"]; | ||
|
||
if (process.env.NODE_ENV !== "production") { | ||
attachLoggerConsoleTransport(logger); | ||
attachLoggerConsoleTransport(rootLogger); | ||
} | ||
|
||
if (typeof window === "undefined") { | ||
import("@saleor/apps-logger/node").then( | ||
async ({ attachLoggerOtelTransport, attachLoggerSentryTransport }) => { | ||
const loggerContext = await import("./logger-context").then((m) => m.loggerContext); | ||
|
||
attachLoggerSentryTransport(logger); | ||
attachLoggerOtelTransport(logger, packageJson.version, loggerContext); | ||
attachLoggerSentryTransport(rootLogger); | ||
attachLoggerOtelTransport(rootLogger, packageJson.version, loggerContext); | ||
}, | ||
); | ||
} | ||
|
||
export { createLogger, logger }; | ||
export const createLogger = (name: string, params?: Record<string, unknown>) => | ||
rootLogger.getSubLogger( | ||
{ | ||
name: name, | ||
}, | ||
params, | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
export { createLogger, logger } from "./src/logger"; | ||
export { attachLoggerConsoleTransport } from "./src/logger-console-transport"; | ||
export { rootLogger } from "./src/root-logger"; |
Oops, something went wrong.