diff --git a/src/main/exceptionHandler.js b/src/main/exceptionHandler.js index 9f4afe06..c26fc2ef 100644 --- a/src/main/exceptionHandler.js +++ b/src/main/exceptionHandler.js @@ -27,7 +27,7 @@ const exceptionToString = (error, type) => { return `Version: ${global.MARKTEXT_VERSION_STRING || app.getVersion()}\n` + `OS: ${getOSInformation()}\n` + `Type: ${type}\n` + - `Date: ${new Date().toGMTString()}\n` + + `Date: ${new Date().toUTCString()}\n` + `Message: ${message}\n` + `Stack: ${stack}\n` } diff --git a/src/main/index.js b/src/main/index.js index 817036f8..7dff8d72 100644 --- a/src/main/index.js +++ b/src/main/index.js @@ -11,7 +11,7 @@ import setupEnvironment from './app/env' import { getLogLevel } from './utils' const initializeLogger = appEnvironment => { - log.transports.console.level = process.env.NODE_ENV === 'development' ? true : 'error' + log.transports.console.level = process.env.NODE_ENV === 'development' ? 'info' : 'error' log.transports.rendererConsole = null log.transports.file.resolvePath = () => path.join(appEnvironment.paths.logPath, 'main.log') log.transports.file.level = getLogLevel() diff --git a/src/main/menu/actions/file.js b/src/main/menu/actions/file.js index 046e2e04..6bd0431e 100644 --- a/src/main/menu/actions/file.js +++ b/src/main/menu/actions/file.js @@ -71,7 +71,7 @@ const handleResponseForExport = async (e, { type, content, pathname, title, page Object.assign(options, getPdfPageOptions(pageOptions)) const data = await win.webContents.printToPDF(options) removePrintServiceFromWindow(win) - await writeFile(filePath, data, extension, {}) + await writeFile(filePath, data, extension, 'binary') } else { if (!content) { throw new Error('No HTML content found.') @@ -221,14 +221,14 @@ ipcMain.on('mt::save-and-close-tabs', async (e, unsavedFiles) => { Promise.all(unsavedFiles.map(file => handleResponseForSave(e, file))) .then(arr => { const tabIds = arr.filter(id => id != null) - win.send('mt::force-close-tabs-by-id', tabIds) + win.webContents.send('mt::force-close-tabs-by-id', tabIds) }) .catch(err => { - log.error('Error while save all:', err.error) + log.error('Error while save all:', err) }) } else { const tabIds = unsavedFiles.map(f => f.id) - win.send('mt::force-close-tabs-by-id', tabIds) + win.webContents.send('mt::force-close-tabs-by-id', tabIds) } }) diff --git a/src/main/preferences/index.js b/src/main/preferences/index.js index 04b61710..a4f6f8d8 100644 --- a/src/main/preferences/index.js +++ b/src/main/preferences/index.js @@ -43,7 +43,7 @@ class Preference extends EventEmitter { defaultSettings.theme = 'dark' } } catch (err) { - log(err) + log.error(err) } if (!defaultSettings) { diff --git a/src/main/windows/editor.js b/src/main/windows/editor.js index 5745d8a6..1afd8d1d 100644 --- a/src/main/windows/editor.js +++ b/src/main/windows/editor.js @@ -203,7 +203,8 @@ class EditorWindow extends BaseWindow { * @param {boolean} [selected] Whether the tab should become the selected tab (true if not set). */ openTab (filePath, options = {}, selected = true) { - if (this.lifecycle === WindowLifecycle.QUITTING) return + // TODO: Don't allow new files if quitting. + if (this.lifecycle === WindowLifecycle.QUITTED) return this.openTabs([{ filePath, options, selected }]) } @@ -226,7 +227,8 @@ class EditorWindow extends BaseWindow { * @param {{filePath: string, selected: boolean, options: any}[]} filePath A list of markdown file paths and options to open. */ openTabs (fileList) { - if (this.lifecycle === WindowLifecycle.QUITTING) return + // TODO: Don't allow new files if quitting. + if (this.lifecycle === WindowLifecycle.QUITTED) return const { browserWindow } = this const { preferences } = this._accessor @@ -259,6 +261,7 @@ class EditorWindow extends BaseWindow { * @param {[string]} markdown The markdown string. */ openUntitledTab (selected = true, markdown = '') { + // TODO: Don't allow new files if quitting. if (this.lifecycle === WindowLifecycle.QUITTED) return if (this.lifecycle === WindowLifecycle.READY) { @@ -275,6 +278,7 @@ class EditorWindow extends BaseWindow { * @param {string} pathname The directory path. */ openFolder (pathname) { + // TODO: Don't allow new files if quitting. if (!pathname || this.lifecycle === WindowLifecycle.QUITTED || isSamePathSync(pathname, this._openedRootDirectory)) { return diff --git a/src/renderer/bootstrap.js b/src/renderer/bootstrap.js index 09ea54af..07b2edb3 100644 --- a/src/renderer/bootstrap.js +++ b/src/renderer/bootstrap.js @@ -7,7 +7,7 @@ let exceptionLogger = s => console.error(s) const configureLogger = () => { const { debug, paths, windowId } = global.marktext.env - log.transports.console.level = process.env.NODE_ENV === 'development' // mirror to window console + log.transports.console.level = process.env.NODE_ENV === 'development' ? 'info' : false // mirror to window console log.transports.mainConsole = null log.transports.file.resolvePath = () => path.join(paths.logPath, `editor-${windowId}.log`) log.transports.file.level = debug ? 'debug' : 'info'