Skip to content

Commit

Permalink
Tidy up logging commands
Browse files Browse the repository at this point in the history
  • Loading branch information
rhyskoedijk committed Dec 3, 2024
1 parent bc17f83 commit 800562c
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
PullRequestAsyncStatus,
PullRequestStatus,
} from 'azure-devops-node-api/interfaces/GitInterfaces';
import { error, warning } from 'azure-pipelines-task-lib/task';
import { debug, error, warning } from 'azure-pipelines-task-lib/task';
import { IHttpClientResponse } from 'typed-rest-client/Interfaces';
import {
IAbandonPullRequest,
Expand Down Expand Up @@ -683,10 +683,10 @@ export class AzureDevOpsWebApiClient {
requestAsync: () => Promise<IHttpClientResponse>,
): Promise<any | undefined> {
// Send the request, ready the response
if (this.debug) console.debug(`🌎 🠊 [${method}] ${url}`);
if (this.debug) debug(`🌎 🠊 [${method}] ${url}`);
const response = await requestAsync();
const body = await response.readBody();
if (this.debug) console.debug(`🌎 🠈 [${response.message.statusCode}] ${response.message.statusMessage}`);
if (this.debug) debug(`🌎 🠈 [${response.message.statusCode}] ${response.message.statusMessage}`);

try {
// Check that the request was successful
Expand All @@ -702,13 +702,13 @@ export class AzureDevOpsWebApiClient {
// In debug mode, log the error, request, and response for debugging
if (this.debug) {
if (payload) {
console.debug('REQUEST:', JSON.stringify(payload, null, 2));
debug(`REQUEST: ${JSON.stringify(payload, null, 2)}`);
}
if (body) {
try {
console.debug('RESPONSE:', JSON.stringify(JSON.parse(body), null, 2));
debug(`RESPONSE: ${JSON.stringify(JSON.parse(body), null, 2)}`);
} catch {
console.debug('RESPONSE:', body); // If the response is not JSON, just log the raw body
debug(`RESPONSE: ${body}`); // If the response is not JSON, just log the raw body
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ function logComponentOutput(

// Log output from all other components
default:
console.log(line);
console.info(line);
break;
}
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { GitPullRequestMergeStrategy, VersionControlChangeType } from 'azure-devops-node-api/interfaces/GitInterfaces';
import { error, warning } from 'azure-pipelines-task-lib/task';
import { debug, error, warning } from 'azure-pipelines-task-lib/task';
import * as path from 'path';
import { AzureDevOpsWebApiClient } from '../azure-devops/AzureDevOpsWebApiClient';
import { section } from '../azure-devops/formattingCommands';
Expand Down Expand Up @@ -65,7 +65,7 @@ export class DependabotOutputProcessor implements IDependabotUpdateOutputProcess

section(`Processing '${type}'`);
if (this.debug) {
console.debug(JSON.stringify(data, null, 2));
debug(JSON.stringify(data, null, 2));
}
switch (type) {
// Documentation on the 'data' model for each output type can be found here:
Expand Down

0 comments on commit 800562c

Please sign in to comment.