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

Use pass in logger for ml modules #969

Merged
merged 1 commit into from
Nov 8, 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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Changed

- Change to use loggers from `LoggerProvider` as default when initialize background blur/replacement processor.

### Fixed

## [3.9.0] - 2024-04-12
Expand Down
8 changes: 2 additions & 6 deletions src/providers/BackgroundBlurProvider/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,8 @@ import {
BackgroundBlurProcessor,
BackgroundBlurVideoFrameProcessor,
BackgroundFilterSpec,
ConsoleLogger,
DefaultVideoTransformDevice,
Device,
LogLevel,
NoOpVideoFrameProcessor,
} from 'amazon-chime-sdk-js';
import React, {
Expand Down Expand Up @@ -51,7 +49,8 @@ export const BackgroundBlurProvider: FC<React.PropsWithChildren<Props>> = ({
options,
children,
}) => {
const logger = useLogger();
let logger = useLogger();
logger = options?.logger || logger;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not just one line let logger = options?.logger || useLogger() ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there's warning for conditionally calling hooks

Copy link

@georgezy-amzn georgezy-amzn Nov 7, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how about const logger = options?.logger ?? useLogger() ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same warning

const [isBackgroundBlurSupported, setIsBackgroundBlurSupported] = useState<
boolean | undefined
>(undefined);
Expand Down Expand Up @@ -158,9 +157,6 @@ export const BackgroundBlurProvider: FC<React.PropsWithChildren<Props>> = ({
);
const currentProcessor = await initializeBackgroundBlur();
try {
const logger =
options?.logger ||
new ConsoleLogger('BackgroundBlurProvider', LogLevel.INFO);
if (currentProcessor) {
const chosenVideoTransformDevice = new DefaultVideoTransformDevice(
logger,
Expand Down
8 changes: 2 additions & 6 deletions src/providers/BackgroundReplacementProvider/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,8 @@ import {
BackgroundReplacementOptions,
BackgroundReplacementProcessor,
BackgroundReplacementVideoFrameProcessor,
ConsoleLogger,
DefaultVideoTransformDevice,
Device,
LogLevel,
NoOpVideoFrameProcessor,
} from 'amazon-chime-sdk-js';
import React, {
Expand Down Expand Up @@ -52,7 +50,8 @@ const BackgroundReplacementProviderContext = createContext<
export const BackgroundReplacementProvider: FC<
React.PropsWithChildren<Props>
> = ({ spec, options, children }) => {
const logger = useLogger();
let logger = useLogger();
logger = options?.logger || logger;
const [
isBackgroundReplacementSupported,
setIsBackgroundReplacementSupported,
Expand Down Expand Up @@ -160,9 +159,6 @@ export const BackgroundReplacementProvider: FC<
);
const currentProcessor = await initializeBackgroundReplacement();
try {
const logger =
options?.logger ||
new ConsoleLogger('BackgroundReplacementProvider', LogLevel.INFO);
if (currentProcessor) {
const chosenVideoTransformDevice = new DefaultVideoTransformDevice(
logger,
Expand Down
Loading