Improve logging for debug artifacts
This commit is contained in:
parent
78d398ebc6
commit
d0a3cf2152
6 changed files with 94 additions and 50 deletions
13
lib/debug-artifacts.js
generated
13
lib/debug-artifacts.js
generated
|
|
@ -40,6 +40,7 @@ const actions_util_1 = require("./actions-util");
|
||||||
const analyze_1 = require("./analyze");
|
const analyze_1 = require("./analyze");
|
||||||
const codeql_1 = require("./codeql");
|
const codeql_1 = require("./codeql");
|
||||||
const environment_1 = require("./environment");
|
const environment_1 = require("./environment");
|
||||||
|
const logging_1 = require("./logging");
|
||||||
const util_1 = require("./util");
|
const util_1 = require("./util");
|
||||||
function sanitizeArtifactName(name) {
|
function sanitizeArtifactName(name) {
|
||||||
return name.replace(/[^a-zA-Z0-9_\\-]+/g, "");
|
return name.replace(/[^a-zA-Z0-9_\\-]+/g, "");
|
||||||
|
|
@ -128,27 +129,37 @@ async function tryUploadAllAvailableDebugArtifacts(config, logger) {
|
||||||
try {
|
try {
|
||||||
const filesToUpload = [];
|
const filesToUpload = [];
|
||||||
for (const language of config.languages) {
|
for (const language of config.languages) {
|
||||||
|
await (0, logging_1.withGroup)(`Uploading debug artifacts for ${language}`, async () => {
|
||||||
|
logger.info("Preparing SARIF result debug artifact...");
|
||||||
const sarifResultDebugArtifact = tryPrepareSarifDebugArtifact(config, language, logger);
|
const sarifResultDebugArtifact = tryPrepareSarifDebugArtifact(config, language, logger);
|
||||||
if (sarifResultDebugArtifact) {
|
if (sarifResultDebugArtifact) {
|
||||||
filesToUpload.push(sarifResultDebugArtifact);
|
filesToUpload.push(sarifResultDebugArtifact);
|
||||||
|
logger.info("SARIF result debug artifact ready for upload.");
|
||||||
}
|
}
|
||||||
// Add any log files
|
logger.info("Preparing database logs debug artifact...");
|
||||||
const databaseDirectory = (0, util_1.getCodeQLDatabasePath)(config, language);
|
const databaseDirectory = (0, util_1.getCodeQLDatabasePath)(config, language);
|
||||||
const logsDirectory = path.resolve(databaseDirectory, "log");
|
const logsDirectory = path.resolve(databaseDirectory, "log");
|
||||||
if ((0, util_1.doesDirectoryExist)(logsDirectory)) {
|
if ((0, util_1.doesDirectoryExist)(logsDirectory)) {
|
||||||
filesToUpload.push(...(0, util_1.listFolder)(logsDirectory));
|
filesToUpload.push(...(0, util_1.listFolder)(logsDirectory));
|
||||||
|
logger.info("Database logs debug artifact ready for upload.");
|
||||||
}
|
}
|
||||||
// Multilanguage tracing: there are additional logs in the root of the cluster
|
// Multilanguage tracing: there are additional logs in the root of the cluster
|
||||||
|
logger.info("Preparing database cluster logs debug artifact...");
|
||||||
const multiLanguageTracingLogsDirectory = path.resolve(config.dbLocation, "log");
|
const multiLanguageTracingLogsDirectory = path.resolve(config.dbLocation, "log");
|
||||||
if ((0, util_1.doesDirectoryExist)(multiLanguageTracingLogsDirectory)) {
|
if ((0, util_1.doesDirectoryExist)(multiLanguageTracingLogsDirectory)) {
|
||||||
filesToUpload.push(...(0, util_1.listFolder)(multiLanguageTracingLogsDirectory));
|
filesToUpload.push(...(0, util_1.listFolder)(multiLanguageTracingLogsDirectory));
|
||||||
|
logger.info("Database cluster logs debug artifact ready for upload.");
|
||||||
}
|
}
|
||||||
// Add database bundle
|
// Add database bundle
|
||||||
|
logger.info("Preparing database bundle debug artifact...");
|
||||||
const databaseBundle = await tryBundleDatabase(config, language, logger);
|
const databaseBundle = await tryBundleDatabase(config, language, logger);
|
||||||
if (databaseBundle) {
|
if (databaseBundle) {
|
||||||
filesToUpload.push(databaseBundle);
|
filesToUpload.push(databaseBundle);
|
||||||
|
logger.info("Database bundle debug artifact ready for upload.");
|
||||||
}
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
logger.info("Uploading debug artifacts...");
|
||||||
await uploadDebugArtifacts(filesToUpload, config.dbLocation, config.debugArtifactName);
|
await uploadDebugArtifacts(filesToUpload, config.dbLocation, config.debugArtifactName);
|
||||||
}
|
}
|
||||||
catch (e) {
|
catch (e) {
|
||||||
|
|
|
||||||
File diff suppressed because one or more lines are too long
10
lib/logging.js
generated
10
lib/logging.js
generated
|
|
@ -25,6 +25,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
exports.getActionsLogger = getActionsLogger;
|
exports.getActionsLogger = getActionsLogger;
|
||||||
exports.getRunnerLogger = getRunnerLogger;
|
exports.getRunnerLogger = getRunnerLogger;
|
||||||
|
exports.withGroup = withGroup;
|
||||||
const core = __importStar(require("@actions/core"));
|
const core = __importStar(require("@actions/core"));
|
||||||
function getActionsLogger() {
|
function getActionsLogger() {
|
||||||
return core;
|
return core;
|
||||||
|
|
@ -44,4 +45,13 @@ function getRunnerLogger(debugMode) {
|
||||||
endGroup: () => undefined,
|
endGroup: () => undefined,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
function withGroup(groupName, f) {
|
||||||
|
core.startGroup(groupName);
|
||||||
|
try {
|
||||||
|
return f();
|
||||||
|
}
|
||||||
|
finally {
|
||||||
|
core.endGroup();
|
||||||
|
}
|
||||||
|
}
|
||||||
//# sourceMappingURL=logging.js.map
|
//# sourceMappingURL=logging.js.map
|
||||||
|
|
@ -1 +1 @@
|
||||||
{"version":3,"file":"logging.js","sourceRoot":"","sources":["../src/logging.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAcA,4CAEC;AAED,0CAcC;AAhCD,oDAAsC;AActC,SAAgB,gBAAgB;IAC9B,OAAO,IAAI,CAAC;AACd,CAAC;AAED,SAAgB,eAAe,CAAC,SAAkB;IAChD,OAAO;QACL,sCAAsC;QACtC,KAAK,EAAE,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,SAAS;QAClD,sCAAsC;QACtC,IAAI,EAAE,OAAO,CAAC,IAAI;QAClB,sCAAsC;QACtC,OAAO,EAAE,OAAO,CAAC,IAAI;QACrB,sCAAsC;QACtC,KAAK,EAAE,OAAO,CAAC,KAAK;QACpB,OAAO,EAAE,GAAG,EAAE,CAAC,SAAS;QACxB,UAAU,EAAE,GAAG,EAAE,CAAC,SAAS;QAC3B,QAAQ,EAAE,GAAG,EAAE,CAAC,SAAS;KAC1B,CAAC;AACJ,CAAC"}
|
{"version":3,"file":"logging.js","sourceRoot":"","sources":["../src/logging.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAcA,4CAEC;AAED,0CAcC;AAED,8BAOC;AAzCD,oDAAsC;AActC,SAAgB,gBAAgB;IAC9B,OAAO,IAAI,CAAC;AACd,CAAC;AAED,SAAgB,eAAe,CAAC,SAAkB;IAChD,OAAO;QACL,sCAAsC;QACtC,KAAK,EAAE,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,SAAS;QAClD,sCAAsC;QACtC,IAAI,EAAE,OAAO,CAAC,IAAI;QAClB,sCAAsC;QACtC,OAAO,EAAE,OAAO,CAAC,IAAI;QACrB,sCAAsC;QACtC,KAAK,EAAE,OAAO,CAAC,KAAK;QACpB,OAAO,EAAE,GAAG,EAAE,CAAC,SAAS;QACxB,UAAU,EAAE,GAAG,EAAE,CAAC,SAAS;QAC3B,QAAQ,EAAE,GAAG,EAAE,CAAC,SAAS;KAC1B,CAAC;AACJ,CAAC;AAED,SAAgB,SAAS,CAAI,SAAiB,EAAE,CAAU;IACxD,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC;IAC3B,IAAI,CAAC;QACH,OAAO,CAAC,EAAE,CAAC;IACb,CAAC;YAAS,CAAC;QACT,IAAI,CAAC,QAAQ,EAAE,CAAC;IAClB,CAAC;AACH,CAAC"}
|
||||||
|
|
@ -12,7 +12,7 @@ import { getCodeQL } from "./codeql";
|
||||||
import { Config } from "./config-utils";
|
import { Config } from "./config-utils";
|
||||||
import { EnvVar } from "./environment";
|
import { EnvVar } from "./environment";
|
||||||
import { Language } from "./languages";
|
import { Language } from "./languages";
|
||||||
import { Logger } from "./logging";
|
import { Logger, withGroup } from "./logging";
|
||||||
import {
|
import {
|
||||||
bundleDb,
|
bundleDb,
|
||||||
doesDirectoryExist,
|
doesDirectoryExist,
|
||||||
|
|
@ -152,6 +152,8 @@ export async function tryUploadAllAvailableDebugArtifacts(
|
||||||
const filesToUpload: string[] = [];
|
const filesToUpload: string[] = [];
|
||||||
|
|
||||||
for (const language of config.languages) {
|
for (const language of config.languages) {
|
||||||
|
await withGroup(`Uploading debug artifacts for ${language}`, async () => {
|
||||||
|
logger.info("Preparing SARIF result debug artifact...");
|
||||||
const sarifResultDebugArtifact = tryPrepareSarifDebugArtifact(
|
const sarifResultDebugArtifact = tryPrepareSarifDebugArtifact(
|
||||||
config,
|
config,
|
||||||
language,
|
language,
|
||||||
|
|
@ -159,31 +161,43 @@ export async function tryUploadAllAvailableDebugArtifacts(
|
||||||
);
|
);
|
||||||
if (sarifResultDebugArtifact) {
|
if (sarifResultDebugArtifact) {
|
||||||
filesToUpload.push(sarifResultDebugArtifact);
|
filesToUpload.push(sarifResultDebugArtifact);
|
||||||
|
logger.info("SARIF result debug artifact ready for upload.");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add any log files
|
logger.info("Preparing database logs debug artifact...");
|
||||||
const databaseDirectory = getCodeQLDatabasePath(config, language);
|
const databaseDirectory = getCodeQLDatabasePath(config, language);
|
||||||
const logsDirectory = path.resolve(databaseDirectory, "log");
|
const logsDirectory = path.resolve(databaseDirectory, "log");
|
||||||
if (doesDirectoryExist(logsDirectory)) {
|
if (doesDirectoryExist(logsDirectory)) {
|
||||||
filesToUpload.push(...listFolder(logsDirectory));
|
filesToUpload.push(...listFolder(logsDirectory));
|
||||||
|
logger.info("Database logs debug artifact ready for upload.");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Multilanguage tracing: there are additional logs in the root of the cluster
|
// Multilanguage tracing: there are additional logs in the root of the cluster
|
||||||
|
logger.info("Preparing database cluster logs debug artifact...");
|
||||||
const multiLanguageTracingLogsDirectory = path.resolve(
|
const multiLanguageTracingLogsDirectory = path.resolve(
|
||||||
config.dbLocation,
|
config.dbLocation,
|
||||||
"log",
|
"log",
|
||||||
);
|
);
|
||||||
if (doesDirectoryExist(multiLanguageTracingLogsDirectory)) {
|
if (doesDirectoryExist(multiLanguageTracingLogsDirectory)) {
|
||||||
filesToUpload.push(...listFolder(multiLanguageTracingLogsDirectory));
|
filesToUpload.push(...listFolder(multiLanguageTracingLogsDirectory));
|
||||||
|
logger.info("Database cluster logs debug artifact ready for upload.");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add database bundle
|
// Add database bundle
|
||||||
const databaseBundle = await tryBundleDatabase(config, language, logger);
|
logger.info("Preparing database bundle debug artifact...");
|
||||||
|
const databaseBundle = await tryBundleDatabase(
|
||||||
|
config,
|
||||||
|
language,
|
||||||
|
logger,
|
||||||
|
);
|
||||||
if (databaseBundle) {
|
if (databaseBundle) {
|
||||||
filesToUpload.push(databaseBundle);
|
filesToUpload.push(databaseBundle);
|
||||||
|
logger.info("Database bundle debug artifact ready for upload.");
|
||||||
}
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
logger.info("Uploading debug artifacts...");
|
||||||
await uploadDebugArtifacts(
|
await uploadDebugArtifacts(
|
||||||
filesToUpload,
|
filesToUpload,
|
||||||
config.dbLocation,
|
config.dbLocation,
|
||||||
|
|
|
||||||
|
|
@ -31,3 +31,12 @@ export function getRunnerLogger(debugMode: boolean): Logger {
|
||||||
endGroup: () => undefined,
|
endGroup: () => undefined,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function withGroup<T>(groupName: string, f: () => T): T {
|
||||||
|
core.startGroup(groupName);
|
||||||
|
try {
|
||||||
|
return f();
|
||||||
|
} finally {
|
||||||
|
core.endGroup();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue