diff --git a/src/utiles/LoggerUtils.js b/src/utiles/LoggerUtils.js index a4264c0..0dffea4 100644 --- a/src/utiles/LoggerUtils.js +++ b/src/utiles/LoggerUtils.js @@ -1,6 +1,8 @@ const {createLogger, format, transports} = require('winston'); const {_, formatDate} = require('../workers/mongo_manager') +const path = require("path"); const {printf, label, timestamp, combine} = format; +const homedir = require('os').homedir(); const myFormat = printf(({level, message, label, timestamp}) => { return `${timestamp} [${label}] ${level}: ${message}`; @@ -14,7 +16,7 @@ const appointmentLogger = createLogger({ myFormat ), transports: [ - new transports.File({filename: "appointment_" + formatDate(new Date()) + ".log"}), + new transports.File({filename: path.join(homedir, "appointment_" + formatDate(new Date()) + ".log")}), ], }); diff --git a/src/workers/CommandorPage.js b/src/workers/CommandorPage.js index 884afdb..70078b7 100644 --- a/src/workers/CommandorPage.js +++ b/src/workers/CommandorPage.js @@ -251,7 +251,7 @@ class CommandorPage { document.getElementsByClassName("btn")[0].click(); }) } catch (e) { - console.log(e) + log(e) } } } @@ -297,10 +297,10 @@ class CommandorPage { await this.checkAudioBtn(); for (let i = 0; i < 15; i++) { await delay(1000) - console.log("will call beep") + log("will call beep") shell.beep() } - console.log("发现datadome"); + log("发现datadome"); } else { if (currentPage.url() === RDV_URL) { await this.fillFields(this.page); @@ -308,7 +308,7 @@ class CommandorPage { await this.getErrors() } else { if (content.includes(MESSAGE_URL_VALIDATION_FR) || content.includes(MESSAGE_URL_VALIDATION_EN)) { - console.log("successful"); + log("successful"); await this.push_message_to_queue(PublishType.SUCCESS); } else { // try to get errors @@ -317,7 +317,7 @@ class CommandorPage { } } } catch (e) { - console.log(e) + log(e) } }