Skip to content

Commit

Permalink
feat(log): log autoupdate info
Browse files Browse the repository at this point in the history
  • Loading branch information
DEgITx committed Feb 12, 2018
1 parent d138c85 commit 1e5392d
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 4 deletions.
10 changes: 7 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@
"debug": "^3.1.0",
"diskusage": "^0.2.4",
"electron-context-menu": "^0.9.1",
"electron-log": "^2.2.14",
"electron-updater": "^2.20.1",
"fs-jetpack": "^1.2.0",
"iconv-lite": "^0.4.19",
Expand Down
13 changes: 12 additions & 1 deletion src/background/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ const logFile = fs.createWriteStream(app.getPath("userData") + '/rats.log', {fla
const logStdout = process.stdout;

console.log = (...d) => {
logFile.write(util.format(...d) + '\n');
const date = (new Date).toLocaleTimeString()
logFile.write(`[${date}] ` + util.format(...d) + '\n');
logStdout.write(util.format(...d) + '\n');
};

Expand Down Expand Up @@ -232,6 +233,16 @@ const startSphinx = (callback) => {
}
}

// log autoupdate
const log = require('electron-log')
log.transports.file.level = false;
log.transports.console.level = false;
log.transports.console = function(msg) {
const text = util.format.apply(util, msg.data);
console.log(text);
};
autoUpdater.logger = log;

autoUpdater.on('update-downloaded', () => {
console.log('update-downloaded lats quitAndInstall');
if (env.name === "production") {
Expand Down

0 comments on commit 1e5392d

Please sign in to comment.