@theia/core 1.58.2 → 1.59.0-next.62
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -6
- package/i18n/nls.json +1 -1
- package/lib/browser/catalog.json +12 -4
- package/lib/browser/logger-frontend-module.d.ts.map +1 -1
- package/lib/browser/logger-frontend-module.js +2 -3
- package/lib/browser/logger-frontend-module.js.map +1 -1
- package/lib/browser/saveable-service.js +1 -1
- package/lib/browser/saveable-service.js.map +1 -1
- package/lib/browser/saveable.d.ts +2 -0
- package/lib/browser/saveable.d.ts.map +1 -1
- package/lib/browser/saveable.js.map +1 -1
- package/lib/common/logger-binding.d.ts +3 -0
- package/lib/common/logger-binding.d.ts.map +1 -0
- package/lib/common/logger-binding.js +36 -0
- package/lib/common/logger-binding.js.map +1 -0
- package/lib/common/logger-protocol.d.ts +1 -1
- package/lib/common/logger-protocol.d.ts.map +1 -1
- package/lib/common/logger-protocol.js +3 -1
- package/lib/common/logger-protocol.js.map +1 -1
- package/lib/common/logger.d.ts +1 -0
- package/lib/common/logger.d.ts.map +1 -1
- package/lib/common/logger.js +12 -1
- package/lib/common/logger.js.map +1 -1
- package/lib/common/resource.d.ts +11 -2
- package/lib/common/resource.d.ts.map +1 -1
- package/lib/common/resource.js +11 -1
- package/lib/common/resource.js.map +1 -1
- package/lib/node/console-logger-server.d.ts +5 -1
- package/lib/node/console-logger-server.d.ts.map +1 -1
- package/lib/node/console-logger-server.js +18 -4
- package/lib/node/console-logger-server.js.map +1 -1
- package/lib/node/logger-backend-module.d.ts.map +1 -1
- package/lib/node/logger-backend-module.js +2 -3
- package/lib/node/logger-backend-module.js.map +1 -1
- package/lib/node/logger-cli-contribution.d.ts +2 -0
- package/lib/node/logger-cli-contribution.d.ts.map +1 -1
- package/lib/node/logger-cli-contribution.js +40 -7
- package/lib/node/logger-cli-contribution.js.map +1 -1
- package/package.json +6 -6
- package/src/browser/logger-frontend-module.ts +3 -4
- package/src/browser/saveable-service.ts +1 -1
- package/src/browser/saveable.ts +2 -0
- package/src/common/logger-binding.ts +34 -0
- package/src/common/logger-protocol.ts +4 -2
- package/src/common/logger.ts +10 -1
- package/src/common/resource.ts +17 -4
- package/src/node/console-logger-server.ts +22 -2
- package/src/node/logger-backend-module.ts +3 -4
- package/src/node/logger-cli-contribution.ts +43 -7
|
@@ -43,6 +43,8 @@ export class LogLevelCliContribution implements CliContribution {
|
|
|
43
43
|
*/
|
|
44
44
|
protected _defaultLogLevel: LogLevel = LogLevel.INFO;
|
|
45
45
|
|
|
46
|
+
protected _logFile?: string;
|
|
47
|
+
|
|
46
48
|
protected logConfigChangedEvent: Emitter<void> = new Emitter<void>();
|
|
47
49
|
|
|
48
50
|
get defaultLogLevel(): LogLevel {
|
|
@@ -53,6 +55,10 @@ export class LogLevelCliContribution implements CliContribution {
|
|
|
53
55
|
return this._logLevels;
|
|
54
56
|
}
|
|
55
57
|
|
|
58
|
+
get logFile(): string | undefined {
|
|
59
|
+
return this._logFile;
|
|
60
|
+
}
|
|
61
|
+
|
|
56
62
|
configure(conf: yargs.Argv): void {
|
|
57
63
|
conf.option('log-level', {
|
|
58
64
|
description: 'Sets the default log level',
|
|
@@ -65,6 +71,12 @@ export class LogLevelCliContribution implements CliContribution {
|
|
|
65
71
|
type: 'string',
|
|
66
72
|
nargs: 1,
|
|
67
73
|
});
|
|
74
|
+
|
|
75
|
+
conf.option('log-file', {
|
|
76
|
+
description: 'Path to the log file',
|
|
77
|
+
type: 'string',
|
|
78
|
+
nargs: 1
|
|
79
|
+
});
|
|
68
80
|
}
|
|
69
81
|
|
|
70
82
|
async setArguments(args: yargs.Arguments): Promise<void> {
|
|
@@ -87,22 +99,46 @@ export class LogLevelCliContribution implements CliContribution {
|
|
|
87
99
|
console.error(`Error reading log config file ${filename}: ${e}`);
|
|
88
100
|
}
|
|
89
101
|
}
|
|
102
|
+
|
|
103
|
+
if (args['log-file'] !== undefined) {
|
|
104
|
+
let filename = args['log-file'] as string;
|
|
105
|
+
try {
|
|
106
|
+
filename = path.resolve(filename);
|
|
107
|
+
try {
|
|
108
|
+
const stat = await fs.stat(filename);
|
|
109
|
+
if (stat && stat.isFile()) {
|
|
110
|
+
// Rename the previous log file to avoid overwriting it
|
|
111
|
+
const oldFilename = `${filename}.${stat.ctime.toISOString().replace(/:/g, '-')}.old`;
|
|
112
|
+
await fs.rename(filename, oldFilename);
|
|
113
|
+
}
|
|
114
|
+
} catch {
|
|
115
|
+
// File does not exist, just continue to create it
|
|
116
|
+
}
|
|
117
|
+
await fs.writeFile(filename, '');
|
|
118
|
+
this._logFile = filename;
|
|
119
|
+
} catch (e) {
|
|
120
|
+
console.error(`Error creating log file ${filename}: ${e}`);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
90
123
|
}
|
|
91
124
|
|
|
92
125
|
protected async watchLogConfigFile(filename: string): Promise<void> {
|
|
93
|
-
|
|
126
|
+
const dir = path.dirname(filename);
|
|
127
|
+
await subscribe(dir, async (err, events) => {
|
|
94
128
|
if (err) {
|
|
95
129
|
console.log(`Error during log file watching ${filename}: ${err}`);
|
|
96
130
|
return;
|
|
97
131
|
}
|
|
98
132
|
try {
|
|
99
133
|
for (const event of events) {
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
134
|
+
if (event.path === filename) {
|
|
135
|
+
switch (event.type) {
|
|
136
|
+
case 'create':
|
|
137
|
+
case 'update':
|
|
138
|
+
await this.slurpLogConfigFile(filename);
|
|
139
|
+
this.logConfigChangedEvent.fire(undefined);
|
|
140
|
+
break;
|
|
141
|
+
}
|
|
106
142
|
}
|
|
107
143
|
}
|
|
108
144
|
} catch (e) {
|