Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[electron] Remove winston as a dependency #3536

Merged
merged 5 commits into from
Jul 29, 2021

Conversation

matheusd
Copy link
Member

This removes the winston log library as a dependency from the project. This helps reduce the number of dependencies on the main electron layer.

This is done by implementing a very basic logger that replicates the features we were using from winston: writing both to a log file and to the terminal when debug is set.

Dependencies of the main electron layer before winston is removed:

electron-deps-winston

After removing winston:
electron-deps-no-winston

);

process.on("uncaughtException", (err) => {
logger.log("error", "UNCAUGHT EXCEPTION", err);
logger.log("error", "UNCAUGHT EXCEPTION: " + err);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

string template

Copy link
Member

@amass01 amass01 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work 🥇
Left some minors

@@ -700,7 +700,7 @@ export const launchDCRWallet = async (
e &&
e.code &&
e.code != "EOF" &&
logger.log("error", "tx stream error", e)
logger.log("error", "tx stream error: " + e)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

string template

@@ -873,7 +872,7 @@ export const launchDCRLnd = (
if (!lastDcrdErr || lastDcrdErr === "") {
lastDcrdErr = lastPanicLine(GetDcrdLogs());
}
logger.log("error", "dcrd closed due to an error: ", lastDcrdErr);
logger.log("error", "dcrd closed due to an error: " + lastDcrdErr);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

string template

const logMsg = args.reduce((a) => a + "%s ", "%s ");
const logArgs = [msg, ...args.map(formatArg)];
const logArgs = args.map(formatArg);
const logMsg = msg + " " + logArgs.join(" ");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

string template

Copy link
Collaborator

@bgptr bgptr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code looks good and works fine.
I found only one critical issue: when I try to navigate to Logs view the application quits with this error message:

/home/bgptr/go/src/github.com/decred/decrediton/app/main.js:729
_fs.default.existsSync(walletsDirectory)||_fs.default.mkdirSync(walletsDirectory,{recursive:true});_fs.default.existsSync(mainnetWalletsPath)||_fs.default.mkdirSync(mainnetWalletsPath,{recursive:true});_fs.default.existsSync(testnetWalletsPath)||_fs.default.mkdirSync(testnetWalletsPath,{recursive:true});(0,_paths.checkAndInitWalletCfg)(true);(0,_paths.checkAndInitWalletCfg)(false);logger.log("info","Using config/data from:"+_electron.app.getPath("userData"));logger.log("info",`Versions: Decrediton: ${_electron.app.getVersion()}, `+`Electron: ${process.versions.electron}, `+`Chrome: ${process.versions.chrome}`);process.on("uncaughtException",err=>{logger.log("error",`UNCAUGHT EXCEPTION: ${err}`);throw err;});const installExtensions=async()=>{if(true){const extensions=[_electronDevtoolsInstaller.REACT_DEVELOPER_TOOLS,_electronDevtoolsInstaller.REDUX_DEVTOOLS];const forceDownload=!!process.env.UPGRADE_EXTENSIONS;for(const name of extensions){try{await(0,_electronDevtoolsInstaller.default)(name,forceDownload);}catch(e){console.log("Error installing extension: "+e);}}}};const{ipcMain}=__webpack_require__(/*! electron */"electron");// handleEvent listens on the given channel for ipcRenderer.invoke() calls and


                                                                  ^

TypeError: Cannot read property 'find' of undefined
    at IpcMainImpl.<anonymous> (/home/bgptr/go/src/github.com/decred/decrediton/app/main.js:8821:42)
    at IpcMainImpl.emit (events.js:315:20)
    at Object.<anonymous> (electron/js2c/browser_init.js:161:10351)
    at Object.emit (events.js:315:20)

@matheusd
Copy link
Member Author

Nice catch! Updated.

@alexlyp alexlyp merged commit 085ad29 into decred:master Jul 29, 2021
@matheusd matheusd deleted the remove-winston branch February 3, 2022 17:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants