From b502d65de28c86499934a8a7045aeb8bc4c0f753 Mon Sep 17 00:00:00 2001 From: Vishwas Shashidhar Date: Thu, 24 Aug 2017 17:16:12 +0530 Subject: [PATCH] electron-97: fixed logging issues for unit tests and added documentation in the README --- README.md | 6 ++++++ js/log.js | 10 +++++++--- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index a99cd53e..20009816 100644 --- a/README.md +++ b/README.md @@ -57,5 +57,11 @@ In order to achieve those goals Symphony is participating and working in close c - code coverage reports are placed in dir: converage - tests are located in dir: tests +## Logging +- Local logging is enabled for dev environments using the module [electron-log](https://www.npmjs.com/package/electron-log) +- On macOS, the logs are stored under `~/Library/Logs//log.log` +- On Windows, the logs are stored under `%USERPROFILE%\AppData\Roaming\\log.log` +- Remote logging is enabled for local and production cases and are sent to the backend server via the remote objects + ## Misc notes If desiring to run against server without proper cert use cmd line option: --ignore-certificate-errors diff --git a/js/log.js b/js/log.js index 83b913d3..8a12eabf 100644 --- a/js/log.js +++ b/js/log.js @@ -1,13 +1,13 @@ 'use strict'; -const electronLog = require('electron-log'); - const getCmdLineArg = require('./utils/getCmdLineArg.js'); const { isDevEnv } = require('./utils/misc'); const logLevels = require('./enums/logLevels.js'); const MAX_LOG_QUEUE_LENGTH = 100; +let electronLog; + class Logger { constructor() { @@ -18,7 +18,9 @@ class Logger { this.logQueue = []; // Initializes the local logger - initializeLocalLogger(); + if (isDevEnv) { + initializeLocalLogger(); + } } /** @@ -99,6 +101,8 @@ let loggerInstance = new Logger(); * Initializes the electron logger for local logging */ function initializeLocalLogger() { +// eslint-disable-next-line global-require + electronLog = require('electron-log'); electronLog.transports.file.level = 'debug'; electronLog.transports.file.format = '{h}:{i}:{s}:{ms} {text}'; electronLog.transports.file.maxSize = 10 * 1024 * 1024;