@theia/core 1.58.3 → 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.
Files changed (49) hide show
  1. package/README.md +6 -6
  2. package/i18n/nls.json +1 -1
  3. package/lib/browser/catalog.json +12 -4
  4. package/lib/browser/logger-frontend-module.d.ts.map +1 -1
  5. package/lib/browser/logger-frontend-module.js +2 -3
  6. package/lib/browser/logger-frontend-module.js.map +1 -1
  7. package/lib/browser/saveable-service.js +1 -1
  8. package/lib/browser/saveable-service.js.map +1 -1
  9. package/lib/browser/saveable.d.ts +2 -0
  10. package/lib/browser/saveable.d.ts.map +1 -1
  11. package/lib/browser/saveable.js.map +1 -1
  12. package/lib/common/logger-binding.d.ts +3 -0
  13. package/lib/common/logger-binding.d.ts.map +1 -0
  14. package/lib/common/logger-binding.js +36 -0
  15. package/lib/common/logger-binding.js.map +1 -0
  16. package/lib/common/logger-protocol.d.ts +1 -1
  17. package/lib/common/logger-protocol.d.ts.map +1 -1
  18. package/lib/common/logger-protocol.js +3 -1
  19. package/lib/common/logger-protocol.js.map +1 -1
  20. package/lib/common/logger.d.ts +1 -0
  21. package/lib/common/logger.d.ts.map +1 -1
  22. package/lib/common/logger.js +12 -1
  23. package/lib/common/logger.js.map +1 -1
  24. package/lib/common/resource.d.ts +11 -2
  25. package/lib/common/resource.d.ts.map +1 -1
  26. package/lib/common/resource.js +11 -1
  27. package/lib/common/resource.js.map +1 -1
  28. package/lib/node/console-logger-server.d.ts +5 -1
  29. package/lib/node/console-logger-server.d.ts.map +1 -1
  30. package/lib/node/console-logger-server.js +18 -4
  31. package/lib/node/console-logger-server.js.map +1 -1
  32. package/lib/node/logger-backend-module.d.ts.map +1 -1
  33. package/lib/node/logger-backend-module.js +2 -3
  34. package/lib/node/logger-backend-module.js.map +1 -1
  35. package/lib/node/logger-cli-contribution.d.ts +2 -0
  36. package/lib/node/logger-cli-contribution.d.ts.map +1 -1
  37. package/lib/node/logger-cli-contribution.js +40 -7
  38. package/lib/node/logger-cli-contribution.js.map +1 -1
  39. package/package.json +6 -6
  40. package/src/browser/logger-frontend-module.ts +3 -4
  41. package/src/browser/saveable-service.ts +1 -1
  42. package/src/browser/saveable.ts +2 -0
  43. package/src/common/logger-binding.ts +34 -0
  44. package/src/common/logger-protocol.ts +4 -2
  45. package/src/common/logger.ts +10 -1
  46. package/src/common/resource.ts +17 -4
  47. package/src/node/console-logger-server.ts +22 -2
  48. package/src/node/logger-backend-module.ts +3 -4
  49. 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
- await subscribe(filename, async (err, events) => {
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
- switch (event.type) {
101
- case 'create':
102
- case 'update':
103
- await this.slurpLogConfigFile(filename);
104
- this.logConfigChangedEvent.fire(undefined);
105
- break;
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) {