Remove default behavior of logging to file

Default behavior of logging to file is no longer needed now that Embark log history can be properly served using the `ProcessLogsApi` and `LogHandler` classes.

# Conflicts:
#	lib/core/logger.js
#	lib/modules/blockchain_process/blockchain.js
This commit is contained in:
emizzle 2018-10-24 09:28:27 +03:00 committed by Pascal Precht
parent f5c77b1416
commit 9a830c3423
No known key found for this signature in database
GPG Key ID: 0EE28D8D6FD85D7D
2 changed files with 5 additions and 9 deletions

View File

@ -14,13 +14,6 @@ class Logger {
this.logFunction = options.logFunction || console.log;
this.logFile = options.logFile;
this.context = options.context;
// Use a default logFile if none is specified in the cli,
// in the format .embark/logs/embark_<context>.log.
if (!this.logFile) {
this.logFile = fs.dappPath(`${constants.logs.logPath}embark_${this.context}.log`);
// creates log dir if it doesn't exist, and overwrites existing log file if it exists
fs.outputFileSync(this.logFile, '');
}
}
/**
@ -86,6 +79,9 @@ Logger.prototype.registerAPICall = function (plugins) {
};
Logger.prototype.writeToFile = function (_txt) {
if (!this.logFile) {
return;
}
const formattedDate = [`[${date.format(new Date(), DATE_FORMAT)}]`]; // adds a timestamp to the logs in the logFile
fs.appendFileSync(this.logFile, "\n" + formattedDate.concat(Array.from(arguments)).join(' '));
};

View File

@ -22,7 +22,7 @@ var Blockchain = function(userConfig, clientClass) {
this.isDev = userConfig.isDev;
this.onReadyCallback = userConfig.onReadyCallback || (() => {});
this.onExitCallback = userConfig.onExitCallback;
this.logger = userConfig.logger || new Logger({logLevel: 'debug'});
this.logger = userConfig.logger || new Logger({logLevel: 'debug', context: constants.contexts.blockchain}); // do not pass in events as we don't want any log events emitted
this.events = userConfig.events;
this.proxyIpc = null;
this.isStandalone = userConfig.isStandalone;
@ -222,7 +222,7 @@ Blockchain.prototype.run = function () {
// TOCHECK I don't understand why stderr and stdout are reverted.
// This happens with Geth and Parity, so it does not seems a client problem
self.child.stdout.on('data', (data) => {
this.logger.info(`${self.client.name} error: ${data}`);
self.logger.info(`${self.client.name} error: ${data}`);
});
self.child.stderr.on('data', async (data) => {