Skip to content

Commit

Permalink
Refactored code
Browse files Browse the repository at this point in the history
  • Loading branch information
Syed-Umair committed May 29, 2018
1 parent f2208c7 commit 607f641
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
11 changes: 5 additions & 6 deletions logger.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ let jsZip = require('jszip');
let appRootDirectory = require('app-root-dir');
let settings;
let ipc;
let instanceList = new Map();
const SETTING_LIST = ['FILE_LOGGING', 'LOGS_EXPIRY', 'ENABLE_BUGSNAG'];
const APP_NAME = getAppName() || 'electron-app';
const LOGSDIR = path.join(getAppDataLoc(), `${APP_NAME}-logs`);
Expand Down Expand Up @@ -76,7 +77,7 @@ function getDefaultOptions() {
isWebview: false,
type: process.type
};
//calculate name based on main-file-location
//calculate name based on main-file-location
options.fileName = process.mainModule
? path.basename(process.mainModule.filename)
: getUniqueId();
Expand Down Expand Up @@ -412,7 +413,6 @@ function handleError(error) {
}

class Logger {

constructor(
{
fileName = getUniqueId(),
Expand All @@ -421,8 +421,8 @@ class Logger {
type = process.type
} = getDefaultOptions()
) {
if (Logger.instanceList[process.pid]) {
return Logger.instanceList[process.pid];
if (instanceList.has(process.pid)) {
return instanceList.get(process.pid);
}
pruneOldLogs();
if (fileName) {
Expand Down Expand Up @@ -451,7 +451,7 @@ class Logger {
console.error(e);
}
}
Logger.instanceList[process.type] = this;
instanceList.set(process.pid, this);
}
debug(...content) {
logIt(this, content, 'debug');
Expand Down Expand Up @@ -533,5 +533,4 @@ class Logger {
});
}
}
Logger.instanceList = {};
module.exports = Logger;
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "logger-electron",
"version": "1.5.7",
"version": "1.5.8",
"description": "Logger For Electron Apps",
"main": "logger.js",
"scripts": {},
Expand All @@ -12,7 +12,7 @@
"author": {
"name": "syed_umair",
"email": "[email protected]",
"url": "ideasyed.ml"
"url": "syedumair.ml"
},
"license": "MIT",
"dependencies": {
Expand Down

0 comments on commit 607f641

Please sign in to comment.