Skip to content

Commit

Permalink
clean up console output by changing REST API calls from console.log t…
Browse files Browse the repository at this point in the history
…o core.debug
  • Loading branch information
mattloveparasoft committed May 27, 2021
1 parent 8e09dea commit 38f96c1
Show file tree
Hide file tree
Showing 8 changed files with 140 additions and 37 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ on: # rebuild any PRs and main branch changes
pull_request:
push:
branches:
- main
- master
- 'releases/*'

jobs:
Expand All @@ -14,4 +14,4 @@ jobs:
- run: |
npm install
- run: |
npm run build
npm run all
142 changes: 117 additions & 25 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

10 changes: 10 additions & 0 deletions dist/licenses.txt

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/sourcemap-register.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "disconnect-server-action",
"version": "1.0.1",
"version": "1.0.2",
"private": true,
"description": "Disconnect Server action",
"main": "lib/main.js",
Expand All @@ -11,7 +11,7 @@
"lint": "eslint src/**/*.ts",
"package": "ncc build --source-map --license licenses.txt",
"test": "jest",
"all": "npm run build && npm run format && npm run lint && npm run package && npm test"
"all": "npm run build && npm run package && npm test"
},
"repository": {
"type": "git",
Expand Down
3 changes: 2 additions & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,11 @@ export async function run(): Promise<void> {

ctpService.findServerInEM<EMSystem>('/api/v2/servers', 'servers', serverValue).then((server: VirtServer) => {
core.debug('Found server ' + serverValue + 'by matching ' + serverType);
core.info('Disconnecting server: ' + server.name);
return ctpService.deleteFromEM<VirtServer>('/api/v2/servers/' + server.id);
}).then((res: VirtServer) => {
if (res.name) {
core.debug('Successfully disconnected server ' + res.name);
core.info('Successfully disconnected server: ' + res.name);
} else {
core.debug('Error deleting server');
core.setFailed('Error deleting server');
Expand Down
10 changes: 5 additions & 5 deletions src/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,15 @@ export class WebService {
if (this.authorization) {
options['auth'] = this.authorization.username + ':' + this.authorization.password;
}
console.log('DELETE ' + this.protocolLabel + '//' + options.host + ':' + options.port + options.path);
core.debug('DELETE ' + this.protocolLabel + '//' + options.host + ':' + options.port + options.path);
var responseString = "";
this.protocol.get(options, (res) => {
res.setEncoding('utf8');
res.on('data', (chunk) => {
responseString += chunk;
});
res.on('end', () => {
console.log(' response ' + res.statusCode + ': ' + responseString);
core.debug(' response ' + res.statusCode + ': ' + responseString);
var responseObject = JSON.parse(responseString);
def.resolve(responseObject);
});
Expand Down Expand Up @@ -90,15 +90,15 @@ export class WebService {
if (this.authorization) {
options['auth'] = this.authorization.username + ':' + this.authorization.password;
}
console.log('GET ' + this.protocolLabel + '//' + options.host + ':' + options.port + options.path);
core.debug('GET ' + this.protocolLabel + '//' + options.host + ':' + options.port + options.path);
var responseString = "";
this.protocol.get(options, (res) => {
res.setEncoding('utf8');
res.on('data', (chunk) => {
responseString += chunk;
});
res.on('end', () => {
console.log(' response ' + res.statusCode + ': ' + responseString);
core.debug(' response ' + res.statusCode + ': ' + responseString);
var responseObject = JSON.parse(responseString);
if (typeof responseObject[property] === 'undefined') {
def.reject(property + ' does not exist in response object from ' + path);
Expand All @@ -125,4 +125,4 @@ export class WebService {
return promise;
};

}
}

0 comments on commit 38f96c1

Please sign in to comment.