mirror of https://github.com/embarklabs/embark.git
fix rebase issues
This commit is contained in:
parent
f7eea63679
commit
e14d5e64a9
|
@ -7,10 +7,7 @@ import { ServicesMonitor } from './services_monitor';
|
|||
|
||||
import { normalizeInput } from 'embark-utils';
|
||||
import { Logger } from 'embark-logger';
|
||||
|
||||
const utils = require('../utils/utils');
|
||||
const Logger = require('embark-logger');
|
||||
const DebugLog = require('embark-structlog');
|
||||
import { DebugLog } from 'embark-structlog';
|
||||
|
||||
const EMBARK_PROCESS_NAME = 'embark';
|
||||
|
||||
|
@ -62,6 +59,8 @@ export class Engine {
|
|||
|
||||
isDev: boolean | undefined;
|
||||
|
||||
debugLog: any;
|
||||
|
||||
constructor(options) {
|
||||
this.env = options.env;
|
||||
this.client = options.client;
|
||||
|
@ -83,6 +82,7 @@ export class Engine {
|
|||
|
||||
init(_options, callback) {
|
||||
callback = callback || function() {};
|
||||
|
||||
const options = _options || {};
|
||||
|
||||
this.debugLog = new DebugLog("embark");
|
||||
|
|
|
@ -2,12 +2,6 @@ import { __ } from 'embark-i18n';
|
|||
const EventEmitter = require('events');
|
||||
const cloneDeep = require('lodash.clonedeep');
|
||||
|
||||
const fs = require('fs-extra');
|
||||
|
||||
function debugEventsEnabled() {
|
||||
return process && process.env && process.env.DEBUGEVENTS;
|
||||
}
|
||||
|
||||
function warnIfLegacy(eventName: string) {
|
||||
const legacyEvents: string[] = [];
|
||||
if (legacyEvents.indexOf(eventName) >= 0) {
|
||||
|
@ -15,44 +9,6 @@ function warnIfLegacy(eventName: string) {
|
|||
}
|
||||
}
|
||||
|
||||
function getOrigin(override) {
|
||||
let origin = ((new Error().stack).split("at ")[3]).trim();
|
||||
origin = origin.split("(")[0].trim();
|
||||
return origin;
|
||||
}
|
||||
|
||||
function log(eventType, eventName, origin?: string) {
|
||||
if (!(debugEventsEnabled())) { return; }
|
||||
if (['end', 'prefinish', 'error', 'new', 'demo', 'block', 'version'].indexOf(eventName) >= 0) {
|
||||
return;
|
||||
}
|
||||
if (eventName.indexOf("log") >= 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
// fs.appendFileSync(".embark/events.log", (new Error().stack) + "\n");
|
||||
if (!origin && origin !== "") {
|
||||
const stack = new Error().stack;
|
||||
if (stack) {
|
||||
origin = stack.split("at ")[3].trim();
|
||||
origin = origin.split("(")[0].trim();
|
||||
}
|
||||
// origin = getOrigin();
|
||||
}
|
||||
|
||||
fs.ensureDirSync(".embark/");
|
||||
fs.appendFileSync(".embark/events.log", eventType + ": " + eventName + " -- (" + origin + ")\n");
|
||||
}
|
||||
|
||||
// const cmdNames = {};
|
||||
//
|
||||
// function trackCmd(cmdName) {
|
||||
// if (!(process && process.env && process.env.DEBUGEVENTS)) return;
|
||||
// let origin = ((new Error().stack).split("at ")[3]).trim();
|
||||
// origin = origin.split("(")[0].trim();
|
||||
// cmdNames[cmdName] = origin;
|
||||
// }
|
||||
|
||||
export class EmbarkEmitter extends EventEmitter {
|
||||
|
||||
constructor(options) {
|
||||
|
@ -74,10 +30,6 @@ export class EmbarkEmitter extends EventEmitter {
|
|||
}
|
||||
}
|
||||
|
||||
// EmbarkEmitter.prototype.log = log;
|
||||
EmbarkEmitter.prototype.log = log;
|
||||
EmbarkEmitter.prototype.getOrigin = getOrigin;
|
||||
|
||||
EmbarkEmitter.prototype._maxListeners = 350;
|
||||
const _on = EmbarkEmitter.prototype.on;
|
||||
const _once = EmbarkEmitter.prototype.once;
|
||||
|
@ -146,7 +98,7 @@ EmbarkEmitter.prototype.request2 = function() {
|
|||
this._emit('request:' + requestName, ...other_args);
|
||||
});
|
||||
|
||||
let ogStack = this.debugLog.getStackTrace();
|
||||
const ogStack = this.debugLog.getStackTrace();
|
||||
|
||||
promise.catch((e) => {
|
||||
if (this.debugLog.isEnabled()) {
|
||||
|
|
|
@ -29,6 +29,8 @@ export class Plugins {
|
|||
|
||||
version: string;
|
||||
|
||||
debugLog: any;
|
||||
|
||||
static deprecated = {
|
||||
'embarkjs-connector-web3': '4.1.0'
|
||||
};
|
||||
|
@ -40,6 +42,7 @@ export class Plugins {
|
|||
this.logger = options.logger;
|
||||
this.events = options.events;
|
||||
this.config = options.config;
|
||||
this.debugLog = options.debugLog;
|
||||
this.context = options.context;
|
||||
this.fs = fs;
|
||||
this.env = options.env;
|
||||
|
@ -76,6 +79,7 @@ export class Plugins {
|
|||
pluginModule: plugin,
|
||||
pluginConfig,
|
||||
logger: this.logger,
|
||||
debugLog: this.debugLog,
|
||||
pluginPath,
|
||||
interceptLogs: this.interceptLogs,
|
||||
events: this.events,
|
||||
|
@ -108,6 +112,7 @@ export class Plugins {
|
|||
pluginModule: plugin,
|
||||
pluginConfig: pluginConfig || {},
|
||||
logger: this.logger,
|
||||
debugLog: this.debugLog,
|
||||
pluginPath,
|
||||
interceptLogs: this.interceptLogs,
|
||||
events: this.events,
|
||||
|
@ -131,11 +136,18 @@ export class Plugins {
|
|||
plugin = plugin.default;
|
||||
}
|
||||
|
||||
let logId = this.debugLog.moduleInit(pluginName);
|
||||
let events = this.debugLog.tagObject(this.events, logId);
|
||||
let logger = this.debugLog.tagObject(this.logger, logId);
|
||||
|
||||
const pluginWrapper = new Plugin({
|
||||
name: pluginName,
|
||||
pluginModule: plugin,
|
||||
pluginConfig,
|
||||
logger: this.logger,
|
||||
debugLog: this.debugLog,
|
||||
logId: logId,
|
||||
events: events,
|
||||
pluginPath,
|
||||
interceptLogs: this.interceptLogs,
|
||||
events: this.events,
|
||||
|
@ -230,7 +242,7 @@ export class Plugins {
|
|||
}
|
||||
|
||||
// TODO: because this is potentially hanging, we should issue a trace warning if the event does not exists
|
||||
runActionsForEvent(eventName, args, cb) {
|
||||
runActionsForEvent(eventName, args, cb, logId) {
|
||||
const self = this;
|
||||
if (typeof (args) === 'function') {
|
||||
cb = args;
|
||||
|
@ -254,31 +266,33 @@ export class Plugins {
|
|||
return 0;
|
||||
});
|
||||
|
||||
this.events.log("ACTION", eventName, "");
|
||||
this.debugLog.log({parent_id: logId, type: "trigger_action", name: eventName, givenLogId: logId, plugins: actionPlugins, inputs: args});
|
||||
|
||||
async.reduce(actionPlugins, args, function(current_args, pluginObj: any, nextEach) {
|
||||
const [plugin, pluginName] = pluginObj;
|
||||
|
||||
self.events.log("== ACTION FOR " + eventName, plugin.action.name, pluginName);
|
||||
let actionLogId = self.debugLog.log({module: pluginName, type: "action_run", name: (eventName + plugin.name), source: pluginName, inputs: current_args});
|
||||
|
||||
if (typeof (args) === 'function') {
|
||||
plugin.action.call(plugin.action, (...params) => {
|
||||
nextEach(...params || current_args);
|
||||
self.debugLog.log({id: actionLogId, outputs: params || current_args});
|
||||
return nextEach(...params || current_args);
|
||||
});
|
||||
} else {
|
||||
plugin.action.call(plugin.action, args, (...params) => {
|
||||
nextEach(...params || current_args);
|
||||
self.debugLog.log({id: actionLogId, outputs: (args, params || current_args)});
|
||||
return nextEach(...params || current_args);
|
||||
});
|
||||
}
|
||||
}, cb);
|
||||
}
|
||||
|
||||
emitAndRunActionsForEvent(eventName, args, cb) {
|
||||
emitAndRunActionsForEvent(eventName, args, cb, logId) {
|
||||
if (typeof (args) === 'function') {
|
||||
cb = args;
|
||||
args = [];
|
||||
}
|
||||
this.events.emit(eventName, args);
|
||||
return this.runActionsForEvent(eventName, args, cb);
|
||||
return this.runActionsForEvent(eventName, args, cb, logId);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue