Skip to content

Commit

Permalink
Logs: improved path support
Browse files Browse the repository at this point in the history
  • Loading branch information
Ryzzzen committed May 24, 2019
1 parent 624ae58 commit 124f15f
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion objects/handlers/LoggingHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,20 @@ function LoggingHandler(level) {

LoggingHandler.prototype.start = function() {
if (this.isRenderer) return this.ipc.sendSync('logging-start');
let logsPath;

if (process.platform === 'linux')
this._folder = require('electron').app.getPath('userData') + '/logs';
else {
try {
this._folder = require('electron').app.getPath('logs');
}
catch(err) {
console.error('Couldn\'t find logs path. Using another one.');
this._folder = path.resolve(__dirname, '/logs');
}
}

this._folder = process.platform === 'linux' ? `${require('electron').app.getPath('userData')}/logs` : `${require('electron').app.getPath('logs')}`;
if (!fs.existsSync(this._folder)) fs.mkdirSync(this._folder);

this._path = path.resolve(this._folder, new Date().toString().slice(0, 24).replace(/:/g, '-') + '.txt');
Expand Down

0 comments on commit 124f15f

Please sign in to comment.