Skip to content

Commit

Permalink
fix: Ensure ID before creating log (#961)
Browse files Browse the repository at this point in the history
  • Loading branch information
Gregor Herdmann authored Sep 21, 2017
1 parent 64d82bb commit 15f524d
Showing 1 changed file with 15 additions and 12 deletions.
27 changes: 15 additions & 12 deletions electron/renderer/static/webview-preload.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,20 +120,23 @@ function replaceGoogleAuth() {

function enableFileLogging() {
const id = new URL(window.location).searchParams.get('id');
const logName = require('../../js/config').CONSOLE_LOG;
const logFilePath = path.join(app.getPath('userData'), 'logs', id, logName);
fs.createFileSync(logFilePath);

const logger = new winston.Logger();
logger.add(winston.transports.File, {
filename: logFilePath,
handleExceptions: true,
});

logger.info(pkg.productName, 'Version', pkg.version);
if (id) {
const logName = require('../../js/config').CONSOLE_LOG;
const logFilePath = path.join(app.getPath('userData'), 'logs', id, logName);
fs.createFileSync(logFilePath);

const logger = new winston.Logger();
logger.add(winston.transports.File, {
filename: logFilePath,
handleExceptions: true,
});

// webapp uses global winston reference to define log level
global.winston = logger;
logger.info(pkg.productName, 'Version', pkg.version);

// webapp uses global winston reference to define log level
global.winston = logger;
}
}

function reportWebappVersion() {
Expand Down

0 comments on commit 15f524d

Please sign in to comment.