electron-97: fixed logging issues for unit tests and added documentation in the README

This commit is contained in:
Vishwas Shashidhar 2017-08-24 17:16:12 +05:30
parent 1819b7f82d
commit b502d65de2
2 changed files with 13 additions and 3 deletions

View File

@ -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 - code coverage reports are placed in dir: converage
- tests are located in dir: tests - 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/<app name>/log.log`
- On Windows, the logs are stored under `%USERPROFILE%\AppData\Roaming\<app name>\log.log`
- Remote logging is enabled for local and production cases and are sent to the backend server via the remote objects
## Misc notes ## Misc notes
If desiring to run against server without proper cert use cmd line option: --ignore-certificate-errors If desiring to run against server without proper cert use cmd line option: --ignore-certificate-errors

View File

@ -1,13 +1,13 @@
'use strict'; 'use strict';
const electronLog = require('electron-log');
const getCmdLineArg = require('./utils/getCmdLineArg.js'); const getCmdLineArg = require('./utils/getCmdLineArg.js');
const { isDevEnv } = require('./utils/misc'); const { isDevEnv } = require('./utils/misc');
const logLevels = require('./enums/logLevels.js'); const logLevels = require('./enums/logLevels.js');
const MAX_LOG_QUEUE_LENGTH = 100; const MAX_LOG_QUEUE_LENGTH = 100;
let electronLog;
class Logger { class Logger {
constructor() { constructor() {
@ -18,7 +18,9 @@ class Logger {
this.logQueue = []; this.logQueue = [];
// Initializes the local logger // Initializes the local logger
initializeLocalLogger(); if (isDevEnv) {
initializeLocalLogger();
}
} }
/** /**
@ -99,6 +101,8 @@ let loggerInstance = new Logger();
* Initializes the electron logger for local logging * Initializes the electron logger for local logging
*/ */
function initializeLocalLogger() { function initializeLocalLogger() {
// eslint-disable-next-line global-require
electronLog = require('electron-log');
electronLog.transports.file.level = 'debug'; electronLog.transports.file.level = 'debug';
electronLog.transports.file.format = '{h}:{i}:{s}:{ms} {text}'; electronLog.transports.file.format = '{h}:{i}:{s}:{ms} {text}';
electronLog.transports.file.maxSize = 10 * 1024 * 1024; electronLog.transports.file.maxSize = 10 * 1024 * 1024;