Skip to content

Commit 2c10497

Browse files
author
Akos Kitta
committed
fix: include all log args in the log message
- In the bundled application, the customized logger that writes the log files bogusly includes only the first message fragment in the log message. This PR ensures all message fragments are included in the final message before it is printed to the console/terminal and persisted to the rotating log files. - Includes messages with `debug` severity in the log. - Disables the ANSI coloring in the CLI daemon log by adding the `NO_COLOR=true` environment variable to the spawned CLI daemon process. - Trims trailing line ending of the daemon log. Signed-off-by: Akos Kitta <[email protected]>
1 parent d79bc0d commit 2c10497

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

Diff for: arduino-ide-extension/src/node/arduino-daemon-impl.ts

+6-2
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import {
99
DisposableCollection,
1010
} from '@theia/core/lib/common/disposable';
1111
import { Event, Emitter } from '@theia/core/lib/common/event';
12+
import { deepClone } from '@theia/core/lib/common/objects';
1213
import { environment } from '@theia/application-package/lib/environment';
1314
import { EnvVariablesServer } from '@theia/core/lib/common/env-variables';
1415
import { BackendApplicationContribution } from '@theia/core/lib/node/backend-application';
@@ -171,7 +172,10 @@ export class ArduinoDaemonImpl
171172
const args = await this.getSpawnArgs();
172173
const cliPath = this.getExecPath();
173174
const ready = new Deferred<{ daemon: ChildProcess; port: string }>();
174-
const options = { shell: true };
175+
const options = {
176+
shell: true,
177+
env: { ...deepClone(process.env), NO_COLOR: String(true) },
178+
};
175179
const daemon = spawn(`"${cliPath}"`, args, options);
176180

177181
// If the process exists right after the daemon gRPC server has started (due to an invalid port, unknown address, TCP port in use, etc.)
@@ -258,7 +262,7 @@ export class ArduinoDaemonImpl
258262
}
259263

260264
protected onData(message: string): void {
261-
this.logger.info(message);
265+
this.logger.info(message.trim());
262266
}
263267

264268
// eslint-disable-next-line @typescript-eslint/no-explicit-any

Diff for: electron/build/patch/backend/main.js

+8-5
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
// From the specs: https://specifications.freedesktop.org/basedir-spec/latest/ar01s03.html
77
// "If $XDG_CONFIG_HOME is either not set or empty, a default equal to $HOME/.config should be used."
88
const os = require('os');
9+
const util = require('util');
910
if (os.platform() === 'linux' && !process.env['XDG_CONFIG_HOME']) {
1011
const { join } = require('path');
1112
const home = process.env['HOME'];
@@ -18,12 +19,14 @@ setup({
1819
appName: 'Arduino IDE',
1920
maxSize: 10 * 1024 * 1024
2021
});
21-
for (const name of ['log', 'trace', 'info', 'warn', 'error']) {
22+
for (const name of ['log', 'trace', 'debug', 'info', 'warn', 'error']) {
2223
const original = console[name];
23-
console[name] = (data => {
24-
original(data);
25-
log(data);
26-
}).bind(console);
24+
console[name] = function () {
25+
const messages = Object.values(arguments);
26+
const message = util.format(...messages)
27+
original(message)
28+
log(message);
29+
}
2730
}
2831

2932
const { BackendApplicationConfigProvider } = require('@theia/core/lib/node/backend-application-config-provider');

0 commit comments

Comments
 (0)