如何在 Azure 通信服务中使用 AzureLogger

How to use AzureLogger in Azure Communication Services

示例代码片段@https://docs.microsoft.com/en-us/azure/communication-services/concepts/troubleshooting-info?tabs=csharp%2Cjavascript%2Cdotnet不完整。我对 JavaScript 模块不够熟悉,无法正常工作。我已将模块添加到 package.json ("@azure/logger": "1.0.1")。当我执行我的代码示例时,我收到以下异常:

Uncaught TypeError: this._azureLogger.info is not a function

文档示例:

import { AzureLogger } from '@azure/logger';
AzureLogger.verbose = (...args) => { console.info(...args); } 
AzureLogger.info = (...args) => { console.info(...args); } 
AzureLogger.warning = (...args) => { console.info(...args); } 
AzureLogger.error = (...args) => { console.info(...args); } 
callClient = new CallClient({logger: AzureLogger});

我失败的尝试:

import { AzureLogger } from '@azure/logger';
const logger = require('@azure/logger');
logger.setLogLevel('verbose');
const callClientOptions: CallClientOptions = { logger };

任何人都可以分享此代码的工作示例吗?

斯科特,谢谢你提出这个问题。产品组正在努力更新您链接的文档以获得长期修复。关于让您畅通无阻的短期修复,能否请您尝试以下示例?

对于由此造成的不便,我们深表歉意,并期待您对以下示例进行验证。

import { createClientLogger, setLogLevel } from '@azure/logger';

            const logger = createClientLogger('ACS');
            setLogLevel('verbose');
            logger.verbose.log = (...args) => { console.log(...args); };
            logger.info.log = (...args) => { console.info(...args) ; };
            logger.warning.log = (...args) => { console.warn(...args); };
            logger.error.log = (...args) => { console.error(...args); };
            const options = { logger: logger };
            this.callClient = new CallClient(options);