Skip to content

Commit

Permalink
[Function Apps][Log Stream] Remove Duplicate Logs (#4630)
Browse files Browse the repository at this point in the history
* update URL for function apps

* update to use getScmUrl

* url
  • Loading branch information
ammanifold authored Feb 24, 2020
1 parent 501a8c0 commit 729793d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
18 changes: 14 additions & 4 deletions client-react/src/pages/app/log-stream/LogStreamDataLoader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import SiteService from '../../../ApiHelpers/SiteService';
import LogService from '../../../utils/LogService';
import { ArmObj } from '../../../models/arm-obj';
import { Site } from '../../../models/site/site';
import { isFunctionApp } from '../../../utils/arm-utils';
import Url from '../../../utils/url';

export interface LogStreamDataLoaderProps {
resourceId: string;
Expand Down Expand Up @@ -135,10 +137,7 @@ class LogStreamDataLoader extends React.Component<LogStreamDataLoaderProps, LogS
if (!this.state.site || !logStreamEnabled(this._logType, this.state.logsEnabled)) {
return;
}
const hostNameSslStates = this.state.site.properties.hostNameSslStates;
const scmHostName = hostNameSslStates.find(h => !!h.name && h.name.includes('.scm.'))!.name;
const suffix = this._logType === LogType.WebServer ? 'http' : '';
const logUrl = `https://${scmHostName}/api/logstream/${suffix}`;
const logUrl = this._setLogUrl();
const token = window.appsvc && window.appsvc.env && window.appsvc.env.armToken;
this._xhReq = new XMLHttpRequest();
this._xhReq.open('GET', logUrl, true);
Expand Down Expand Up @@ -178,6 +177,17 @@ class LogStreamDataLoader extends React.Component<LogStreamDataLoaderProps, LogS
}
}
};

private _setLogUrl = (): string => {
const scmUrl = Url.getScmUrl(this.state.site);

if (isFunctionApp(this.state.site) && this._logType === LogType.Application) {
return `${scmUrl}/api/logstream/application/functions/host`;
}

const suffix = this._logType === LogType.WebServer ? 'http' : '';
return `${scmUrl}/api/logstream/${suffix}`;
};
}

export default LogStreamDataLoader;
6 changes: 3 additions & 3 deletions client-react/src/utils/url.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,10 @@ export default class Url {
public static getScmUrl(site: ArmObj<Site>) {
if (window.appsvc && window.appsvc.env.runtimeType.toLowerCase() === 'standalone') {
return this.getMainUrl(site);
} else {
const scmHost = site.properties.hostNameSslStates && site.properties.hostNameSslStates.find(s => s.hostType === HostType.Repository);
return scmHost ? `https://${scmHost.name}` : this.getMainUrl(site);
}

const scmHost = site.properties.hostNameSslStates && site.properties.hostNameSslStates.find(s => s.hostType === HostType.Repository);
return scmHost ? `https://${scmHost.name}` : this.getMainUrl(site);
}

public static getSyncTriggerUrl(site: ArmObj<Site>) {
Expand Down

0 comments on commit 729793d

Please sign in to comment.