Skip to content

Commit 92cc10d

Browse files
committed
refactor(ng-dev): append logging to the log file live instead of only writing the file on exit (#2360)
Append logging live instead of writing to the file on exit. PR Close #2360
1 parent 4294fc6 commit 92cc10d

File tree

11 files changed

+143
-68
lines changed

11 files changed

+143
-68
lines changed

.github/local-actions/branch-manager/main.js

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18339,7 +18339,7 @@ var require_summary = __commonJS({
1833918339
exports.summary = exports.markdownSummary = exports.SUMMARY_DOCS_URL = exports.SUMMARY_ENV_VAR = void 0;
1834018340
var os_1 = __require("os");
1834118341
var fs_1 = __require("fs");
18342-
var { access, appendFile, writeFile } = fs_1.promises;
18342+
var { access, appendFile: appendFile2, writeFile } = fs_1.promises;
1834318343
exports.SUMMARY_ENV_VAR = "GITHUB_STEP_SUMMARY";
1834418344
exports.SUMMARY_DOCS_URL = "https://docs.github.com/actions/using-workflows/workflow-commands-for-github-actions#adding-a-job-summary";
1834518345
var Summary = class {
@@ -18375,7 +18375,7 @@ var require_summary = __commonJS({
1837518375
return __awaiter(this, void 0, void 0, function* () {
1837618376
const overwrite = !!(options === null || options === void 0 ? void 0 : options.overwrite);
1837718377
const filePath = yield this.filePath();
18378-
const writeFunc = overwrite ? writeFile : appendFile;
18378+
const writeFunc = overwrite ? writeFile : appendFile2;
1837918379
yield writeFunc(filePath, this._buffer, { encoding: "utf8" });
1838018380
return this.emptyBuffer();
1838118381
});
@@ -55959,6 +55959,8 @@ ${stderr}`);
5595955959
}
5596055960

5596155961
//
55962+
import { appendFile } from "fs/promises";
55963+
import { stripVTControlCharacters } from "util";
5596255964
var LogLevel;
5596355965
(function(LogLevel2) {
5596455966
LogLevel2[LogLevel2["SILENT"] = 0] = "SILENT";
@@ -56004,7 +56006,7 @@ function runConsoleCommand(loadCommand, logLevel, ...text) {
5600456006
if (getLogLevel() >= logLevel) {
5600556007
loadCommand()(...text);
5600656008
}
56007-
printToLogFile(logLevel, ...text);
56009+
appendToLogFile(logLevel, ...text);
5600856010
}
5600956011
function getLogLevel() {
5601056012
const logLevel = Object.keys(LogLevel).indexOf((process.env[`LOG_LEVEL`] || "").toUpperCase());
@@ -56013,12 +56015,22 @@ function getLogLevel() {
5601356015
}
5601456016
return logLevel;
5601556017
}
56016-
var LOGGED_TEXT = "";
5601756018
var LOG_LEVEL_COLUMNS = 7;
56018-
function printToLogFile(logLevel, ...text) {
56019+
var logFilePath = void 0;
56020+
function appendToLogFile(logLevel, ...text) {
56021+
if (logFilePath === void 0) {
56022+
return;
56023+
}
56024+
if (logLevel === void 0) {
56025+
appendFile(logFilePath, text.join(" "));
56026+
return;
56027+
}
5601956028
const logLevelText = `${LogLevel[logLevel]}:`.padEnd(LOG_LEVEL_COLUMNS);
56020-
LOGGED_TEXT += text.join(" ").split("\n").map((l) => `${logLevelText} ${l}
56021-
`).join("");
56029+
appendFile(
56030+
logFilePath,
56031+
stripVTControlCharacters(text.join(" ").split("\n").map((l) => `${logLevelText} ${l}
56032+
`).join(""))
56033+
);
5602256034
}
5602356035

5602456036
//

.github/local-actions/changelog/main.js

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18339,7 +18339,7 @@ var require_summary = __commonJS({
1833918339
exports.summary = exports.markdownSummary = exports.SUMMARY_DOCS_URL = exports.SUMMARY_ENV_VAR = void 0;
1834018340
var os_1 = __require("os");
1834118341
var fs_1 = __require("fs");
18342-
var { access, appendFile, writeFile } = fs_1.promises;
18342+
var { access, appendFile: appendFile2, writeFile } = fs_1.promises;
1834318343
exports.SUMMARY_ENV_VAR = "GITHUB_STEP_SUMMARY";
1834418344
exports.SUMMARY_DOCS_URL = "https://docs.github.com/actions/using-workflows/workflow-commands-for-github-actions#adding-a-job-summary";
1834518345
var Summary = class {
@@ -18375,7 +18375,7 @@ var require_summary = __commonJS({
1837518375
return __awaiter(this, void 0, void 0, function* () {
1837618376
const overwrite = !!(options === null || options === void 0 ? void 0 : options.overwrite);
1837718377
const filePath = yield this.filePath();
18378-
const writeFunc = overwrite ? writeFile : appendFile;
18378+
const writeFunc = overwrite ? writeFile : appendFile2;
1837918379
yield writeFunc(filePath, this._buffer, { encoding: "utf8" });
1838018380
return this.emptyBuffer();
1838118381
});
@@ -55832,6 +55832,8 @@ ${stderr}`);
5583255832
}
5583355833

5583455834
//
55835+
import { appendFile } from "fs/promises";
55836+
import { stripVTControlCharacters } from "util";
5583555837
var LogLevel;
5583655838
(function(LogLevel2) {
5583755839
LogLevel2[LogLevel2["SILENT"] = 0] = "SILENT";
@@ -55877,7 +55879,7 @@ function runConsoleCommand(loadCommand, logLevel, ...text) {
5587755879
if (getLogLevel() >= logLevel) {
5587855880
loadCommand()(...text);
5587955881
}
55880-
printToLogFile(logLevel, ...text);
55882+
appendToLogFile(logLevel, ...text);
5588155883
}
5588255884
function getLogLevel() {
5588355885
const logLevel = Object.keys(LogLevel).indexOf((process.env[`LOG_LEVEL`] || "").toUpperCase());
@@ -55886,12 +55888,22 @@ function getLogLevel() {
5588655888
}
5588755889
return logLevel;
5588855890
}
55889-
var LOGGED_TEXT = "";
5589055891
var LOG_LEVEL_COLUMNS = 7;
55891-
function printToLogFile(logLevel, ...text) {
55892+
var logFilePath = void 0;
55893+
function appendToLogFile(logLevel, ...text) {
55894+
if (logFilePath === void 0) {
55895+
return;
55896+
}
55897+
if (logLevel === void 0) {
55898+
appendFile(logFilePath, text.join(" "));
55899+
return;
55900+
}
5589255901
const logLevelText = `${LogLevel[logLevel]}:`.padEnd(LOG_LEVEL_COLUMNS);
55893-
LOGGED_TEXT += text.join(" ").split("\n").map((l) => `${logLevelText} ${l}
55894-
`).join("");
55902+
appendFile(
55903+
logFilePath,
55904+
stripVTControlCharacters(text.join(" ").split("\n").map((l) => `${logLevelText} ${l}
55905+
`).join(""))
55906+
);
5589555907
}
5589655908

5589755909
//

apps/prs/src/app/login/login.component.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@ import {AccountService} from '../../../../shared/account/account.service.js';
88
styleUrls: ['./login.component.scss'],
99
})
1010
export class LoginComponent {
11-
constructor(private account: AccountService, private router: Router) {}
11+
constructor(
12+
private account: AccountService,
13+
private router: Router,
14+
) {}
1215

1316
signIn() {
1417
this.account.signInWithGoogle().then((signedIn) => {

apps/prs/src/app/pr-table/pr-table.component.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,10 @@ export class PrTableComponent implements AfterViewInit {
3030
/** The header row definition. */
3131
@ViewChild(MatHeaderRowDef, {static: true}) tableHeaderRow!: MatHeaderRowDef;
3232

33-
constructor(private injector: Injector, private vcr: ViewContainerRef) {}
33+
constructor(
34+
private injector: Injector,
35+
private vcr: ViewContainerRef,
36+
) {}
3437

3538
ngAfterViewInit(): void {
3639
const columns = this.columns.map((column) => {

bazel/api-golden/module_mappings.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,8 @@ export async function resolveTypePackages(typePackageNames: string[]): Promise<{
2727

2828
for (const typePackageName of typePackageNames) {
2929
const moduleNames = getModuleNamesForTypePackage(typePackageName);
30-
const {entryPointTypeFile, resolvedPackageDir} = await resolveTypeDeclarationOfPackage(
31-
typePackageName,
32-
);
30+
const {entryPointTypeFile, resolvedPackageDir} =
31+
await resolveTypeDeclarationOfPackage(typePackageName);
3332

3433
typeFiles.push(entryPointTypeFile);
3534

bazel/map-size-tracking/size_tracker.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,10 @@ import {
1717
} from './file_size_data.js';
1818

1919
export class SizeTracker {
20-
constructor(private filePath: string, private sourceMapPath: string) {}
20+
constructor(
21+
private filePath: string,
22+
private sourceMapPath: string,
23+
) {}
2124

2225
/**
2326
* Computes the file size data by analyzing the input file through

github-actions/create-pr-for-changes/main.js

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18330,7 +18330,7 @@ var require_summary = __commonJS({
1833018330
exports.summary = exports.markdownSummary = exports.SUMMARY_DOCS_URL = exports.SUMMARY_ENV_VAR = void 0;
1833118331
var os_1 = __require("os");
1833218332
var fs_1 = __require("fs");
18333-
var { access, appendFile, writeFile } = fs_1.promises;
18333+
var { access, appendFile: appendFile2, writeFile } = fs_1.promises;
1833418334
exports.SUMMARY_ENV_VAR = "GITHUB_STEP_SUMMARY";
1833518335
exports.SUMMARY_DOCS_URL = "https://docs.github.com/actions/using-workflows/workflow-commands-for-github-actions#adding-a-job-summary";
1833618336
var Summary = class {
@@ -18366,7 +18366,7 @@ var require_summary = __commonJS({
1836618366
return __awaiter(this, void 0, void 0, function* () {
1836718367
const overwrite = !!(options === null || options === void 0 ? void 0 : options.overwrite);
1836818368
const filePath = yield this.filePath();
18369-
const writeFunc = overwrite ? writeFile : appendFile;
18369+
const writeFunc = overwrite ? writeFile : appendFile2;
1837018370
yield writeFunc(filePath, this._buffer, { encoding: "utf8" });
1837118371
return this.emptyBuffer();
1837218372
});
@@ -40768,6 +40768,8 @@ ${stderr}`);
4076840768
}
4076940769

4077040770
//
40771+
import { appendFile } from "fs/promises";
40772+
import { stripVTControlCharacters } from "util";
4077140773
var LogLevel;
4077240774
(function(LogLevel2) {
4077340775
LogLevel2[LogLevel2["SILENT"] = 0] = "SILENT";
@@ -40813,7 +40815,7 @@ function runConsoleCommand(loadCommand, logLevel, ...text) {
4081340815
if (getLogLevel() >= logLevel) {
4081440816
loadCommand()(...text);
4081540817
}
40816-
printToLogFile(logLevel, ...text);
40818+
appendToLogFile(logLevel, ...text);
4081740819
}
4081840820
function getLogLevel() {
4081940821
const logLevel = Object.keys(LogLevel).indexOf((process.env[`LOG_LEVEL`] || "").toUpperCase());
@@ -40822,12 +40824,22 @@ function getLogLevel() {
4082240824
}
4082340825
return logLevel;
4082440826
}
40825-
var LOGGED_TEXT = "";
4082640827
var LOG_LEVEL_COLUMNS = 7;
40827-
function printToLogFile(logLevel, ...text) {
40828+
var logFilePath = void 0;
40829+
function appendToLogFile(logLevel, ...text) {
40830+
if (logFilePath === void 0) {
40831+
return;
40832+
}
40833+
if (logLevel === void 0) {
40834+
appendFile(logFilePath, text.join(" "));
40835+
return;
40836+
}
4082840837
const logLevelText = `${LogLevel[logLevel]}:`.padEnd(LOG_LEVEL_COLUMNS);
40829-
LOGGED_TEXT += text.join(" ").split("\n").map((l) => `${logLevelText} ${l}
40830-
`).join("");
40838+
appendFile(
40839+
logFilePath,
40840+
stripVTControlCharacters(text.join(" ").split("\n").map((l) => `${logLevelText} ${l}
40841+
`).join(""))
40842+
);
4083140843
}
4083240844

4083340845
//

github-actions/feature-request/src/testing.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
import {GitHubAPI, GitHubIssueAPI, Issue, Comment, Query, User} from './api.js';
22

33
export class APIMock implements GitHubAPI {
4-
constructor(public issues: IssueAPIMock[], public orgMembers: OrgMembers) {}
4+
constructor(
5+
public issues: IssueAPIMock[],
6+
public orgMembers: OrgMembers,
7+
) {}
58

69
query(_: Query) {
710
const self = this;

github-actions/slash-commands/main.js

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18338,7 +18338,7 @@ var require_summary = __commonJS({
1833818338
exports.summary = exports.markdownSummary = exports.SUMMARY_DOCS_URL = exports.SUMMARY_ENV_VAR = void 0;
1833918339
var os_1 = __require("os");
1834018340
var fs_1 = __require("fs");
18341-
var { access, appendFile, writeFile } = fs_1.promises;
18341+
var { access, appendFile: appendFile2, writeFile } = fs_1.promises;
1834218342
exports.SUMMARY_ENV_VAR = "GITHUB_STEP_SUMMARY";
1834318343
exports.SUMMARY_DOCS_URL = "https://docs.github.com/actions/using-workflows/workflow-commands-for-github-actions#adding-a-job-summary";
1834418344
var Summary = class {
@@ -18374,7 +18374,7 @@ var require_summary = __commonJS({
1837418374
return __awaiter(this, void 0, void 0, function* () {
1837518375
const overwrite = !!(options === null || options === void 0 ? void 0 : options.overwrite);
1837618376
const filePath = yield this.filePath();
18377-
const writeFunc = overwrite ? writeFile : appendFile;
18377+
const writeFunc = overwrite ? writeFile : appendFile2;
1837818378
yield writeFunc(filePath, this._buffer, { encoding: "utf8" });
1837918379
return this.emptyBuffer();
1838018380
});
@@ -52692,6 +52692,8 @@ ${stderr}`);
5269252692
}
5269352693

5269452694
//
52695+
import { appendFile } from "fs/promises";
52696+
import { stripVTControlCharacters } from "util";
5269552697
var LogLevel;
5269652698
(function(LogLevel2) {
5269752699
LogLevel2[LogLevel2["SILENT"] = 0] = "SILENT";
@@ -52737,7 +52739,7 @@ function runConsoleCommand(loadCommand, logLevel, ...text) {
5273752739
if (getLogLevel() >= logLevel) {
5273852740
loadCommand()(...text);
5273952741
}
52740-
printToLogFile(logLevel, ...text);
52742+
appendToLogFile(logLevel, ...text);
5274152743
}
5274252744
function getLogLevel() {
5274352745
const logLevel = Object.keys(LogLevel).indexOf((process.env[`LOG_LEVEL`] || "").toUpperCase());
@@ -52746,12 +52748,22 @@ function getLogLevel() {
5274652748
}
5274752749
return logLevel;
5274852750
}
52749-
var LOGGED_TEXT = "";
5275052751
var LOG_LEVEL_COLUMNS = 7;
52751-
function printToLogFile(logLevel, ...text) {
52752+
var logFilePath = void 0;
52753+
function appendToLogFile(logLevel, ...text) {
52754+
if (logFilePath === void 0) {
52755+
return;
52756+
}
52757+
if (logLevel === void 0) {
52758+
appendFile(logFilePath, text.join(" "));
52759+
return;
52760+
}
5275252761
const logLevelText = `${LogLevel[logLevel]}:`.padEnd(LOG_LEVEL_COLUMNS);
52753-
LOGGED_TEXT += text.join(" ").split("\n").map((l) => `${logLevelText} ${l}
52754-
`).join("");
52762+
appendFile(
52763+
logFilePath,
52764+
stripVTControlCharacters(text.join(" ").split("\n").map((l) => `${logLevelText} ${l}
52765+
`).join(""))
52766+
);
5275552767
}
5275652768

5275752769
//

ng-dev/format/formatters/base-formatter.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,10 @@ export abstract class Formatter {
5050
/** The default matchers for the formatter for filtering files to be formatted. */
5151
abstract defaultFileMatcher: string[];
5252

53-
constructor(protected git: GitClient, protected config: FormatConfig) {}
53+
constructor(
54+
protected git: GitClient,
55+
protected config: FormatConfig,
56+
) {}
5457

5558
/**
5659
* Retrieve the command to execute the provided action, including both the binary

0 commit comments

Comments
 (0)