Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: export types from logger module #7292

Merged
merged 2 commits into from
Oct 28, 2024
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
5 changes: 5 additions & 0 deletions .changeset/eighty-turkeys-marry.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@vue-storefront/sdk": patch
---

Export types from sdk logger module
34 changes: 2 additions & 32 deletions packages/sdk/src/modules/loggerModule/index.ts
Original file line number Diff line number Diff line change
@@ -1,32 +1,2 @@
import { LoggerFactory, LoggerType } from "@vue-storefront/logger";
import type { Module } from "../../types";
import type { LoggerModuleConfig } from "./types";
import { injectMetadata } from "./injectMetadata";
import { isInvalidConfig } from "./utils";

export const loggerModule = (options?: LoggerModuleConfig) => {
const logger =
options?.handler ?? LoggerFactory.create(LoggerType.ConsolaGcp, options);

if (isInvalidConfig(options)) {
console.warn(
`Both 'handler' and other config options are provided to logger's configuration.
In such case 'handler' will be used and other options will be ignored as those are
supported only by the built-in logger.
If you want to use other options, please remove 'handler' from the configuration.
If you want to use your handler, please remove other options from the configuration.`
);
}

const loggerWithMetadata = injectMetadata(logger, {
alokai: {
context: "storefront",
},
});

return {
connector: {
...loggerWithMetadata,
},
} satisfies Module;
};
export { loggerModule } from "./module";
export * from "./types";
32 changes: 32 additions & 0 deletions packages/sdk/src/modules/loggerModule/module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { LoggerFactory, LoggerType } from "@vue-storefront/logger";
import type { Module } from "../../types";
import type { LoggerModuleConfig } from "./types";
import { injectMetadata } from "./injectMetadata";
import { isInvalidConfig } from "./utils";

export const loggerModule = (options?: LoggerModuleConfig) => {
const logger =
options?.handler ?? LoggerFactory.create(LoggerType.ConsolaGcp, options);

if (isInvalidConfig(options)) {
console.warn(
`Both 'handler' and other config options are provided to logger's configuration.
In such case 'handler' will be used and other options will be ignored as those are
supported only by the built-in logger.
If you want to use other options, please remove 'handler' from the configuration.
If you want to use your handler, please remove other options from the configuration.`
);
}

const loggerWithMetadata = injectMetadata(logger, {
alokai: {
context: "storefront",
},
});

return {
connector: {
...loggerWithMetadata,
},
} satisfies Module;
};
Loading