Skip to content

Commit ed2d755

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

File tree

11 files changed

+125
-68
lines changed

11 files changed

+125
-68
lines changed

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

Lines changed: 15 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,7 @@ ${stderr}`);
5595955959
}
5596055960

5596155961
//
55962+
import { appendFile } from "fs/promises";
5596255963
var LogLevel;
5596355964
(function(LogLevel2) {
5596455965
LogLevel2[LogLevel2["SILENT"] = 0] = "SILENT";
@@ -56004,7 +56005,7 @@ function runConsoleCommand(loadCommand, logLevel, ...text) {
5600456005
if (getLogLevel() >= logLevel) {
5600556006
loadCommand()(...text);
5600656007
}
56007-
printToLogFile(logLevel, ...text);
56008+
appendToLogFile(logLevel, ...text);
5600856009
}
5600956010
function getLogLevel() {
5601056011
const logLevel = Object.keys(LogLevel).indexOf((process.env[`LOG_LEVEL`] || "").toUpperCase());
@@ -56013,12 +56014,19 @@ function getLogLevel() {
5601356014
}
5601456015
return logLevel;
5601556016
}
56016-
var LOGGED_TEXT = "";
5601756017
var LOG_LEVEL_COLUMNS = 7;
56018-
function printToLogFile(logLevel, ...text) {
56018+
var logFilePath = void 0;
56019+
function appendToLogFile(logLevel, ...text) {
56020+
if (logFilePath === void 0) {
56021+
return;
56022+
}
56023+
if (logLevel === void 0) {
56024+
appendFile(logFilePath, text.join(" "));
56025+
return;
56026+
}
5601956027
const logLevelText = `${LogLevel[logLevel]}:`.padEnd(LOG_LEVEL_COLUMNS);
56020-
LOGGED_TEXT += text.join(" ").split("\n").map((l) => `${logLevelText} ${l}
56021-
`).join("");
56028+
appendFile(logFilePath, text.join(" ").split("\n").map((l) => `${logLevelText} ${l}
56029+
`).join("").replace(/\x1B\[([0-9]{1,3}(;[0-9]{1,2})?)?[mGK]/g, ""));
5602256030
}
5602356031

5602456032
//

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

Lines changed: 15 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,7 @@ ${stderr}`);
5583255832
}
5583355833

5583455834
//
55835+
import { appendFile } from "fs/promises";
5583555836
var LogLevel;
5583655837
(function(LogLevel2) {
5583755838
LogLevel2[LogLevel2["SILENT"] = 0] = "SILENT";
@@ -55877,7 +55878,7 @@ function runConsoleCommand(loadCommand, logLevel, ...text) {
5587755878
if (getLogLevel() >= logLevel) {
5587855879
loadCommand()(...text);
5587955880
}
55880-
printToLogFile(logLevel, ...text);
55881+
appendToLogFile(logLevel, ...text);
5588155882
}
5588255883
function getLogLevel() {
5588355884
const logLevel = Object.keys(LogLevel).indexOf((process.env[`LOG_LEVEL`] || "").toUpperCase());
@@ -55886,12 +55887,19 @@ function getLogLevel() {
5588655887
}
5588755888
return logLevel;
5588855889
}
55889-
var LOGGED_TEXT = "";
5589055890
var LOG_LEVEL_COLUMNS = 7;
55891-
function printToLogFile(logLevel, ...text) {
55891+
var logFilePath = void 0;
55892+
function appendToLogFile(logLevel, ...text) {
55893+
if (logFilePath === void 0) {
55894+
return;
55895+
}
55896+
if (logLevel === void 0) {
55897+
appendFile(logFilePath, text.join(" "));
55898+
return;
55899+
}
5589255900
const logLevelText = `${LogLevel[logLevel]}:`.padEnd(LOG_LEVEL_COLUMNS);
55893-
LOGGED_TEXT += text.join(" ").split("\n").map((l) => `${logLevelText} ${l}
55894-
`).join("");
55901+
appendFile(logFilePath, text.join(" ").split("\n").map((l) => `${logLevelText} ${l}
55902+
`).join("").replace(/\x1B\[([0-9]{1,3}(;[0-9]{1,2})?)?[mGK]/g, ""));
5589555903
}
5589655904

5589755905
//

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: 15 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,7 @@ ${stderr}`);
4076840768
}
4076940769

4077040770
//
40771+
import { appendFile } from "fs/promises";
4077140772
var LogLevel;
4077240773
(function(LogLevel2) {
4077340774
LogLevel2[LogLevel2["SILENT"] = 0] = "SILENT";
@@ -40813,7 +40814,7 @@ function runConsoleCommand(loadCommand, logLevel, ...text) {
4081340814
if (getLogLevel() >= logLevel) {
4081440815
loadCommand()(...text);
4081540816
}
40816-
printToLogFile(logLevel, ...text);
40817+
appendToLogFile(logLevel, ...text);
4081740818
}
4081840819
function getLogLevel() {
4081940820
const logLevel = Object.keys(LogLevel).indexOf((process.env[`LOG_LEVEL`] || "").toUpperCase());
@@ -40822,12 +40823,19 @@ function getLogLevel() {
4082240823
}
4082340824
return logLevel;
4082440825
}
40825-
var LOGGED_TEXT = "";
4082640826
var LOG_LEVEL_COLUMNS = 7;
40827-
function printToLogFile(logLevel, ...text) {
40827+
var logFilePath = void 0;
40828+
function appendToLogFile(logLevel, ...text) {
40829+
if (logFilePath === void 0) {
40830+
return;
40831+
}
40832+
if (logLevel === void 0) {
40833+
appendFile(logFilePath, text.join(" "));
40834+
return;
40835+
}
4082840836
const logLevelText = `${LogLevel[logLevel]}:`.padEnd(LOG_LEVEL_COLUMNS);
40829-
LOGGED_TEXT += text.join(" ").split("\n").map((l) => `${logLevelText} ${l}
40830-
`).join("");
40837+
appendFile(logFilePath, text.join(" ").split("\n").map((l) => `${logLevelText} ${l}
40838+
`).join("").replace(/\x1B\[([0-9]{1,3}(;[0-9]{1,2})?)?[mGK]/g, ""));
4083140839
}
4083240840

4083340841
//

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: 15 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,7 @@ ${stderr}`);
5269252692
}
5269352693

5269452694
//
52695+
import { appendFile } from "fs/promises";
5269552696
var LogLevel;
5269652697
(function(LogLevel2) {
5269752698
LogLevel2[LogLevel2["SILENT"] = 0] = "SILENT";
@@ -52737,7 +52738,7 @@ function runConsoleCommand(loadCommand, logLevel, ...text) {
5273752738
if (getLogLevel() >= logLevel) {
5273852739
loadCommand()(...text);
5273952740
}
52740-
printToLogFile(logLevel, ...text);
52741+
appendToLogFile(logLevel, ...text);
5274152742
}
5274252743
function getLogLevel() {
5274352744
const logLevel = Object.keys(LogLevel).indexOf((process.env[`LOG_LEVEL`] || "").toUpperCase());
@@ -52746,12 +52747,19 @@ function getLogLevel() {
5274652747
}
5274752748
return logLevel;
5274852749
}
52749-
var LOGGED_TEXT = "";
5275052750
var LOG_LEVEL_COLUMNS = 7;
52751-
function printToLogFile(logLevel, ...text) {
52751+
var logFilePath = void 0;
52752+
function appendToLogFile(logLevel, ...text) {
52753+
if (logFilePath === void 0) {
52754+
return;
52755+
}
52756+
if (logLevel === void 0) {
52757+
appendFile(logFilePath, text.join(" "));
52758+
return;
52759+
}
5275252760
const logLevelText = `${LogLevel[logLevel]}:`.padEnd(LOG_LEVEL_COLUMNS);
52753-
LOGGED_TEXT += text.join(" ").split("\n").map((l) => `${logLevelText} ${l}
52754-
`).join("");
52761+
appendFile(logFilePath, text.join(" ").split("\n").map((l) => `${logLevelText} ${l}
52762+
`).join("").replace(/\x1B\[([0-9]{1,3}(;[0-9]{1,2})?)?[mGK]/g, ""));
5275552763
}
5275652764

5275752765
//

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)