From 88f013225eb01be44a8d23f2dd213a8dfebd7bfe Mon Sep 17 00:00:00 2001 From: Albert Zak Date: Mon, 20 Jun 2022 22:30:52 +0200 Subject: [PATCH] Add logging to native printing, bump --- app/electron/main/print.js | 14 +++++++++++++- app/electron/package.json | 2 +- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/app/electron/main/print.js b/app/electron/main/print.js index 71b364fd9..938d5f1ba 100644 --- a/app/electron/main/print.js +++ b/app/electron/main/print.js @@ -6,11 +6,15 @@ const { shell, ipcMain } = require('electron') const logger = require('./logger') const start = (options) => { + logger.info('print setup') temp.track() - ipcMain.on('print', (e, printOptions) => { + logger.info('print tracking') + ipcMain.on('print', (e, printOptions) => { + logger.info('print called') const { title, physical, printer, flags, localPath, base64 } = printOptions if (physical && (base64 || localPath)) { + logger.info('print physical') const args = { printer, win32: flags @@ -37,10 +41,12 @@ const start = (options) => { }) }) } else if (localPath) { + logger.info('print localPath') logger.info(`[print] physical local path file "${localPath}" on printer "${printer}" with flags ${JSON.stringify(args)}`) pdfToPrinter.print(localPath, args) } } else { + logger.info('print toPdf') options.title = title printToPdf(options) } @@ -48,7 +54,9 @@ const start = (options) => { } const printToPdf = (options) => { + logger.info('print making temp') temp.mkdir('rosalind', (err, tmpDir) => { + logger.info('print made') if (err) { return logger.error(err) } const pdfPath = path.join(tmpDir, (options.title || 'Print') + '.pdf') @@ -59,18 +67,22 @@ const printToPdf = (options) => { landscape: true } + logger.info('print calling ipcReceiver.printToPDF') options.ipcReceiver.printToPDF(printOptions, (err, data) => { if (err) { logger.error('[Print] Failed to generate pdf: ' + err) return } + logger.info('print writing file') fs.writeFile(pdfPath, data, (err) => { if (err) { logger.error('[Print] Failed to save pdf: ' + err) return } logger.info('[Print] Saved pdf to path: ' + pdfPath) + + logger.info('print opening file') const ok = shell.openItem(pdfPath) if (!ok) { logger.error('[Print] failed to open pdf: ' + pdfPath) diff --git a/app/electron/package.json b/app/electron/package.json index 5c0221620..f9d0f4c8d 100644 --- a/app/electron/package.json +++ b/app/electron/package.json @@ -1,7 +1,7 @@ { "name": "rosalind", "productName": "Rosalind", - "version": "0.0.261", + "version": "0.0.262", "private": true, "description": "Rosalind", "author": {