Skip to content

Commit 30421f0

Browse files
Akos Kittakittaakos
Akos Kitta
authored andcommitted
Enabled file logging for the backend process.
Signed-off-by: Akos Kitta <kittaakos@typefox.io>
1 parent daa2579 commit 30421f0

File tree

2 files changed

+33
-1
lines changed

2 files changed

+33
-1
lines changed

electron/build/patch/main.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// @ts-check
2+
const { setup, log } = require('node-log-rotate');
3+
setup({
4+
appName: 'Arduino Pro IDE',
5+
maxSize: 10 * 1024 * 1024
6+
});
7+
for (const name of ['log', 'trace', 'info', 'warn', 'error']) {
8+
const original = console[name];
9+
console[name] = (data => {
10+
original(data);
11+
log(data);
12+
}).bind(console);
13+
}
14+
15+
const { BackendApplicationConfigProvider } = require('@theia/core/lib/node/backend-application-config-provider');
16+
const main = require('@theia/core/lib/node/main');
17+
BackendApplicationConfigProvider.set({
18+
"configDirName": ".arduinoProIDE",
19+
"singleInstance": true
20+
});
21+
22+
const serverModule = require('./server');
23+
const serverAddress = main.start(serverModule());
24+
serverAddress.then(function ({ port, address }) {
25+
if (process && process.send) {
26+
process.send({ port, address });
27+
}
28+
});
29+
module.exports = serverAddress;

electron/build/template-package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
"resolutions": {
55
"**/fs-extra": "^4.0.3"
66
},
7+
"dependencies": {
8+
"node-log-rotate": "^0.1.5"
9+
},
710
"devDependencies": {
811
"@theia/cli": "next",
912
"cross-env": "^7.0.2",
@@ -19,7 +22,7 @@
1922
"package": "cross-env DEBUG=* && electron-builder --publish=never",
2023
"package:publish": "cross-env DEBUG=* && electron-builder --publish=always",
2124
"download:plugins": "theia download:plugins",
22-
"patch": "ncp ./patch/electron-main.js ./src-gen/frontend/electron-main.js"
25+
"patch": "ncp ./patch/electron-main.js ./src-gen/frontend/electron-main.js && ncp ./patch/main.js ./src-gen/backend/main.js"
2326
},
2427
"engines": {
2528
"node": ">=10.11.0 <13"

0 commit comments

Comments
 (0)