Skip to content

Fix: Warning message shown when clicking on LUIS trace #2160

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

Merged
merged 2 commits into from
Jun 24, 2020
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
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,13 @@ export class Inspector extends React.Component<InspectorProps, InspectorState> {
this.sendInitializationStackToInspector();
};

private handleLoggingFromExtension = (logLevel: LogLevel, argument: string): void => {
const { documentId } = this.props.document;
const inspectorName = this._state.titleOverride || this.state.inspector.name || 'inspector';
const text = `[${inspectorName}] ${argument}`;
logService.logToDocument(documentId, logEntry(textItem(logLevel, text)));
};

private ipcMessageEventHandler = (event: IpcMessageEvent): void => {
// TODO - localization
const { channel } = event;
Expand All @@ -442,14 +449,16 @@ export class Inspector extends React.Component<InspectorProps, InspectorState> {
break;

case EmulatorChannel.Log:
case EmulatorChannel.LogError: {
const logLevel = channel === 'logger.log' ? LogLevel.Info : LogLevel.Error;
const { documentId } = this.props.document;
const inspectorName = this._state.titleOverride || this.state.inspector.name || 'inspector';
const text = `[${inspectorName}] ${event.args[0]}`;
logService.logToDocument(documentId, logEntry(textItem(logLevel, text)));
this.handleLoggingFromExtension(LogLevel.Info, event.args[0]);
break;

case EmulatorChannel.LogError:
this.handleLoggingFromExtension(LogLevel.Error, event.args[0]);
break;

case EmulatorChannel.LogWarn:
this.handleLoggingFromExtension(LogLevel.Warn, event.args[0]);
break;
}

case EmulatorChannel.LogLuisDeepLink: {
const { documentId } = this.props.document;
Expand Down
3 changes: 3 additions & 0 deletions packages/app/main/src/extensions/inspector-preload.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,9 @@ window.host = {
logLuisEditorDeepLink: function(message) {
ipcRenderer.sendToHost('logger.luis-editor-deep-link', message);
},
warn: function(message) {
ipcRenderer.sendToHost('logger.warn', message);
},
},

on: function(event, handler) {
Expand Down
5 changes: 4 additions & 1 deletion packages/extensions/luis/client/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,10 @@ export class App extends Component<any, AppState> {
}
} catch (err) {
// Throw an auth error only if conversation is from a bot file instead of URL.
if (!$host.bot && err.statusCode === 401) {
if (err.statusCode === 401) {
if ($host.bot) {
$host.logger.warn(err.message);
}
return;
}
$host.logger.error(err.message);
Expand Down
1 change: 1 addition & 0 deletions packages/sdk/client/src/extensions/host.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ export interface InspectorHost {
readonly logger: {
log(message: string): () => void;
error(message: string): () => void;
warn(message: string): () => void;
logLuisEditorDeepLink(message: string): () => void;
};

Expand Down
1 change: 1 addition & 0 deletions packages/sdk/shared/src/types/ipc/extensionChannel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export enum EmulatorChannel {
EnableAccessory = 'enable-accessory',
Log = 'logger.log',
LogError = 'logger.error',
LogWarn = 'logger.warn',
LogLuisDeepLink = 'logger.luis-editor-deep-link',
SetAccessoryState = 'set-accessory-state',
SetHightlightedObjects = 'set-highlighted-objects',
Expand Down