Skip to content

Commit

Permalink
Bump 0.1.7
Browse files Browse the repository at this point in the history
- Added simple logging to main process
  • Loading branch information
itssimple committed Dec 17, 2018
1 parent 5cd1f31 commit 3bbd3d4
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 8 deletions.
11 changes: 10 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,14 @@
"name": "CMDR NoLifeKing",
"email": "[email protected]"
},
"os": [
"win32",
"!darwin",
"!linux"
],
"cpu": [
"x64"
],
"repository": {
"type": "github",
"url": "https://github.com/FuelRats/RatTracker-electron"
Expand All @@ -13,6 +21,7 @@
"private": true,
"homepage": "./",
"dependencies": {
"electron-log": "^2.2.17",
"electron-updater": "^4.0.6",
"mobx": "^5.6.0",
"mobx-react": "^5.4.2",
Expand Down Expand Up @@ -77,4 +86,4 @@
"typescript": "^3.1.6",
"wait-on": "^3.2.0"
}
}
}
34 changes: 27 additions & 7 deletions src/rattracker-electron.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,20 @@ const {
BrowserWindow
} = require('electron');

process.on('uncaughtException', e => {
alert('Oops, looks like I made something break, again.. Quitting application!');
const log = require('electron-log');

const startupDate = new Date().toISOString().replace(/\:/g, '-').replace(/\./g, '-');

log.transports.file.level = 'debug';
let logPath = log.transports.file.findLogPath().replace('log.log', `log-${startupDate}.log`);
console.log(logPath);
log.transports.file.file = logPath;
log.transports.console.level = 'debug';

log.info('Application started');

process.on('uncaughtException', e => {
log.error(e);
app.exit(1);
});

Expand All @@ -24,6 +35,7 @@ const files = journalReader.FileReader.loadLogFiles();
journalReader.FileReader.monitorChanges(files);

global.JournalReader = journalReader;
global.Logger = log;

let win;

Expand Down Expand Up @@ -72,7 +84,6 @@ function createWindow() {
});

win.loadURL(rtURL);

edOverlay.loadURL(overlayURL);

if (!!process.env.ELECTRON_START_URL) {
Expand Down Expand Up @@ -102,7 +113,6 @@ function createWindow() {
});*/

win.webContents.on('will-navigate', function (event, newUrl) {
console.log(newUrl);
if (newUrl.indexOf('https://fuelrats.com/authorize') >= 0) {
ratAuth.req = qs.parse(newUrl.split('?')[1]);
}
Expand Down Expand Up @@ -137,11 +147,13 @@ function createWindow() {
});

win.on('closed', () => {
log.info('Closing main window');
edOverlay.close();
win = null;
});

edOverlay.on('closed', () => {
log.info('Closing overlay window');
edOverlay = null;
});
}
Expand All @@ -150,22 +162,30 @@ setInterval(() => {
var d = journalReader.Data();

if (d.Online && typeof d.Status.GuiFocus != 'undefined' && d.Status.GuiFocus == 0) {
if (!edOverlay.isVisible())
edOverlay.showInactive();
if (!edOverlay.isVisible()) {
log.info('Showing overlay');
log.debug(d);
edOverlay.show();
}
} else {
if (edOverlay.isVisible())
if (edOverlay.isVisible()) {
log.info('Hiding overlay');
log.debug(d);
edOverlay.hide();
}
}
}, 1000);

app.on('ready', createWindow);

app.on('before-quit', () => {
log.info('Preparing to quit application');
win.close();
edOverlay.close();
});

app.on('window-all-closed', () => {
log.info('Application exited');
if (process.platform !== 'darwin') {
app.quit();
}
Expand Down
5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2469,6 +2469,11 @@ electron-download@^3.0.1:
semver "^5.3.0"
sumchecker "^1.2.0"

electron-log@^2.2.17:
version "2.2.17"
resolved "https://registry.yarnpkg.com/electron-log/-/electron-log-2.2.17.tgz#e71e2ebb949fc96ded7cdb99eeee7202e48981d2"
integrity sha512-v+Af5W5z99ehhaLOfE9eTSXUwjzh2wFlQjz51dvkZ6ZIrET6OB/zAZPvsuwT6tm3t5x+M1r+Ed3U3xtPZYAyuQ==

[email protected]:
version "0.4.11"
resolved "https://registry.yarnpkg.com/electron-osx-sign/-/electron-osx-sign-0.4.11.tgz#8377732fe7b207969f264b67582ee47029ce092f"
Expand Down

0 comments on commit 3bbd3d4

Please sign in to comment.