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
- 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
If desiring to run against server without proper cert use cmd line option: --ignore-certificate-errors

View File

@ -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,8 +18,10 @@ class Logger {
this.logQueue = [];
// Initializes the local logger
if (isDevEnv) {
initializeLocalLogger();
}
}
/**
* Send log messages from main process to logger hosted by
@ -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;