mirror of https://github.com/embarklabs/embark.git
refactor
This commit is contained in:
parent
db56fe213f
commit
4cb55c796b
|
@ -0,0 +1,4 @@
|
|||
engine-strict = true
|
||||
package-lock = false
|
||||
save-exact = true
|
||||
scripts-prepend-node-path = true
|
|
@ -0,0 +1,101 @@
|
|||
# Change Log
|
||||
|
||||
All notable changes to this project will be documented in this file.
|
||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||
|
||||
# [5.0.0-alpha.1](https://github.com/embark-framework/embark/compare/v5.0.0-alpha.0...v5.0.0-alpha.1) (2019-11-05)
|
||||
|
||||
**Note:** Version bump only for package embark-logger
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# [5.0.0-alpha.0](https://github.com/embark-framework/embark/compare/v4.1.1...v5.0.0-alpha.0) (2019-10-28)
|
||||
|
||||
|
||||
### Build System
|
||||
|
||||
* bump all packages' engines settings ([#1985](https://github.com/embark-framework/embark/issues/1985)) ([ed02cc8](https://github.com/embark-framework/embark/commit/ed02cc8))
|
||||
|
||||
|
||||
### BREAKING CHANGES
|
||||
|
||||
* node: >=10.17.0 <12.0.0
|
||||
npm: >=6.11.3
|
||||
yarn: >=1.19.1
|
||||
|
||||
node v10.17.0 is the latest in the 10.x series and is still in the Active LTS
|
||||
lifecycle. Embark is still not compatible with node's 12.x and 13.x
|
||||
series (because of some dependencies), otherwise it would probably make sense
|
||||
to bump our minimum supported node version all the way to the most recent 12.x
|
||||
release.
|
||||
|
||||
npm v6.11.3 is the version that's bundled with node v10.17.0.
|
||||
|
||||
yarn v1.19.1 is the most recent version as of the time node v10.17.0 was
|
||||
released.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## [4.1.1](https://github.com/embark-framework/embark/compare/v4.1.0...v4.1.1) (2019-08-28)
|
||||
|
||||
**Note:** Version bump only for package embark-logger
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# [4.1.0](https://github.com/embark-framework/embark/compare/v4.1.0-beta.6...v4.1.0) (2019-08-12)
|
||||
|
||||
**Note:** Version bump only for package embark-logger
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# [4.1.0-beta.6](https://github.com/embark-framework/embark/compare/v4.1.0-beta.5...v4.1.0-beta.6) (2019-08-09)
|
||||
|
||||
**Note:** Version bump only for package embark-logger
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# [4.1.0-beta.5](https://github.com/embark-framework/embark/compare/v4.1.0-beta.4...v4.1.0-beta.5) (2019-07-10)
|
||||
|
||||
**Note:** Version bump only for package embark-logger
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# [4.1.0-beta.4](https://github.com/embark-framework/embark/compare/v4.1.0-beta.3...v4.1.0-beta.4) (2019-06-27)
|
||||
|
||||
**Note:** Version bump only for package embark-logger
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# [4.1.0-beta.3](https://github.com/embark-framework/embark/compare/v4.1.0-beta.2...v4.1.0-beta.3) (2019-06-07)
|
||||
|
||||
**Note:** Version bump only for package embark-logger
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# [4.1.0-beta.2](https://github.com/embark-framework/embark/compare/v4.1.0-beta.1...v4.1.0-beta.2) (2019-05-22)
|
||||
|
||||
**Note:** Version bump only for package embark-logger
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# [4.1.0-beta.1](https://github.com/embark-framework/embark/compare/v4.1.0-beta.0...v4.1.0-beta.1) (2019-05-15)
|
||||
|
||||
**Note:** Version bump only for package embark-logger
|
|
@ -0,0 +1,6 @@
|
|||
# `embark-structlog`
|
||||
|
||||
> Debug Logger utility for Embark
|
||||
|
||||
Visit [embark.status.im](https://embark.status.im/) to get started with
|
||||
[Embark](https://github.com/embark-framework/embark).
|
|
@ -0,0 +1,60 @@
|
|||
{
|
||||
"name": "embark-structlog",
|
||||
"version": "5.0.0-alpha.1",
|
||||
"author": "Iuri Matias <iuri.matias@gmail.com>",
|
||||
"contributors": [],
|
||||
"description": "Debug Logging utilities for Embark",
|
||||
"homepage": "https://github.com/embark-framework/embark/tree/master/packages/core/structlog#readme",
|
||||
"bugs": "https://github.com/embark-framework/embark/issues",
|
||||
"keywords": [
|
||||
"blockchain",
|
||||
"dapps",
|
||||
"ethereum",
|
||||
"ipfs",
|
||||
"serverless",
|
||||
"solc",
|
||||
"solidity"
|
||||
],
|
||||
"files": [
|
||||
"dist"
|
||||
],
|
||||
"license": "MIT",
|
||||
"repository": {
|
||||
"directory": "packages/core/structlog",
|
||||
"type": "git",
|
||||
"url": "https://github.com/embark-framework/embark.git"
|
||||
},
|
||||
"main": "./dist/index.js",
|
||||
"embark-collective": {
|
||||
"build:node": true
|
||||
},
|
||||
"scripts": {
|
||||
"_build": "npm run solo -- build",
|
||||
"ci": "npm run qa",
|
||||
"clean": "npm run reset",
|
||||
"lint": "eslint src/",
|
||||
"qa": "npm-run-all lint _build",
|
||||
"reset": "npx rimraf dist embark-*.tgz package",
|
||||
"solo": "embark-solo"
|
||||
},
|
||||
"eslintConfig": {
|
||||
"extends": "../../../.eslintrc.json"
|
||||
},
|
||||
"dependencies": {
|
||||
"@babel/runtime-corejs3": "7.6.3",
|
||||
"fs-extra": "8.1.0",
|
||||
"json-stringify-safe": "5.0.1",
|
||||
"uuid": "3.3.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"embark-solo": "^5.0.0-alpha.0",
|
||||
"eslint": "5.7.0",
|
||||
"npm-run-all": "4.1.5",
|
||||
"rimraf": "3.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=10.17.0 <12.0.0",
|
||||
"npm": ">=6.11.3",
|
||||
"yarn": ">=1.19.1"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,111 @@
|
|||
// const Logger = require('embark-logger');
|
||||
const uuid = require('uuid');
|
||||
const fs = require('fs-extra');
|
||||
import stringify from "json-stringify-safe";
|
||||
|
||||
function jsonFunctionReplacer(_key, value) {
|
||||
if (typeof value === 'function') {
|
||||
return value.toString();
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
// var DB = {
|
||||
// }
|
||||
|
||||
// class SuperLog extends Logger {
|
||||
class SuperLog {
|
||||
|
||||
constructor(processIdentifier) {
|
||||
this.logfile = "./structlog-" + (processIdentifier || "log") + ".json";
|
||||
}
|
||||
|
||||
addRecord(data) {
|
||||
// DB[data.id] = data
|
||||
fs.appendFileSync(this.logfile, "\n" + stringify(data, jsonFunctionReplacer, 0));
|
||||
}
|
||||
|
||||
// findRecord(id) {
|
||||
// return DB[id];
|
||||
// }
|
||||
|
||||
updateRecord(id, data) {
|
||||
// DB[id] = { ...DB[id], ...data }
|
||||
fs.appendFileSync(this.logfile, "\n" + stringify(data, jsonFunctionReplacer, 0));
|
||||
}
|
||||
|
||||
startSession() {
|
||||
this.session = uuid.v4();
|
||||
|
||||
this.modules = {}
|
||||
|
||||
this.addRecord({
|
||||
session: this.session,
|
||||
id: this.session,
|
||||
timestamp: Date.now(),
|
||||
value: "new_session",
|
||||
type: "new_session",
|
||||
name: "new_session"
|
||||
})
|
||||
}
|
||||
|
||||
moduleInit(name) {
|
||||
let id = uuid.v4();
|
||||
|
||||
this.addRecord({
|
||||
session: this.session,
|
||||
id: id,
|
||||
timestamp: Date.now(),
|
||||
parent_id: this.session,
|
||||
type: 'module_init',
|
||||
value: name,
|
||||
name: name
|
||||
})
|
||||
|
||||
this.modules[name] = id
|
||||
|
||||
return id;
|
||||
}
|
||||
|
||||
log(values) {
|
||||
if (values.id) {
|
||||
this.updateRecord(values.id, values)
|
||||
return values.id;
|
||||
}
|
||||
|
||||
let id = uuid.v4();
|
||||
|
||||
if (values.module) {
|
||||
values.parent_id = this.modules[values.module] || this.session
|
||||
} else if (!values.parent_id) {
|
||||
values.parent_id = this.session
|
||||
}
|
||||
|
||||
this.addRecord({
|
||||
session: this.session,
|
||||
timestamp: Date.now(),
|
||||
id: id,
|
||||
...values
|
||||
}, this.db)
|
||||
|
||||
return id;
|
||||
}
|
||||
|
||||
info() {
|
||||
let id = uuid.v4();
|
||||
this.log({
|
||||
session: this.session,
|
||||
timestamp: Date.now(),
|
||||
parent_id: this.session,
|
||||
id: id,
|
||||
type: "log_info",
|
||||
name: "info: " + arguments[0]
|
||||
})
|
||||
// super.info(...arguments);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
module.exports = SuperLog;
|
||||
|
||||
|
|
@ -108,6 +108,7 @@
|
|||
"embark-solidity": "^5.0.0-alpha.1",
|
||||
"embark-specialconfigs": "^5.0.0-alpha.1",
|
||||
"embark-storage": "^5.0.0-alpha.1",
|
||||
"embark-structlog": "^5.0.0-alpha.1",
|
||||
"embark-swarm": "^5.0.0-alpha.1",
|
||||
"embark-test-runner": "^5.0.0-alpha.1",
|
||||
"embark-transaction-logger": "^5.0.0-alpha.1",
|
||||
|
|
|
@ -2,8 +2,8 @@ import {__} from 'embark-i18n';
|
|||
import {dappPath, embarkPath} from 'embark-utils';
|
||||
let async = require('async');
|
||||
const constants = require('embark-core/constants');
|
||||
// const Logger = require('embark-logger');
|
||||
const Logger = require('../lib/core/superlog.js');
|
||||
const Logger = require('embark-logger');
|
||||
// const Logger = require('../lib/core/superlog.js');
|
||||
const {reset: embarkReset, paths: defaultResetPaths} = require('embark-reset');
|
||||
const fs = require('../lib/core/fs.js');
|
||||
const cloneDeep = require('clone-deep');
|
||||
|
@ -27,6 +27,7 @@ class EmbarkController {
|
|||
let Events = require('../lib/core/events.js');
|
||||
let Config = require('../lib/core/config.js');
|
||||
|
||||
// TODO: doesn't seem to be used or necessary
|
||||
this.events = new Events();
|
||||
this.logger = new Logger({logLevel: Logger.logLevels.debug, events: this.events, context: this.context});
|
||||
|
||||
|
@ -154,7 +155,7 @@ class EmbarkController {
|
|||
engine.logger.info(__("loaded plugins") + ": " + pluginList.join(", "));
|
||||
}
|
||||
|
||||
let runId = engine.logger.moduleInit("run_command")
|
||||
let runId = engine.debugLog.moduleInit("run_command")
|
||||
let _events = Object.assign({}, engine.events, {logId: runId, logger: engine.logger});
|
||||
Object.setPrototypeOf(_events, engine.events);
|
||||
engine.events = _events;
|
||||
|
@ -746,10 +747,10 @@ class EmbarkController {
|
|||
engine.logger.info(__("loaded plugins") + ": " + pluginList.join(", "));
|
||||
}
|
||||
|
||||
let runId = engine.logger.moduleInit("test command")
|
||||
let _events = Object.assign({}, engine.events, {logId: runId, logger: engine.logger});
|
||||
Object.setPrototypeOf(_events, engine.events);
|
||||
engine.events = _events;
|
||||
// let runId = engine.logger.moduleInit("test command")
|
||||
// let _events = Object.assign({}, engine.events, {logId: runId, logger: engine.logger});
|
||||
// Object.setPrototypeOf(_events, engine.events);
|
||||
// engine.events = _events;
|
||||
|
||||
engine.registerModuleGroup("coreComponents");
|
||||
engine.registerModuleGroup("stackComponents");
|
||||
|
|
|
@ -45,6 +45,7 @@ var Config = function(options) {
|
|||
this.chainsFile = options.chainsFile || './chains.json';
|
||||
this.plugins = options.plugins;
|
||||
this.logger = options.logger;
|
||||
this.debugLog = options.debugLog;
|
||||
this.package = PACKAGE;
|
||||
this.events = options.events;
|
||||
this.embarkConfig = {};
|
||||
|
@ -131,6 +132,7 @@ Config.prototype.loadConfigFiles = function(options) {
|
|||
this.plugins = new Plugins({
|
||||
plugins: this.embarkConfig.plugins,
|
||||
logger: this.logger,
|
||||
debugLog: this.debugLog,
|
||||
interceptLogs: interceptLogs,
|
||||
events: this.events,
|
||||
config: this,
|
||||
|
|
|
@ -3,8 +3,8 @@ import {ProcessManager, IPC} from 'embark-core';
|
|||
const EMBARK_PROCESS_NAME = 'embark';
|
||||
|
||||
const utils = require('../utils/utils');
|
||||
// const Logger = require('embark-logger');
|
||||
const Logger = require('./superlog.js');
|
||||
const Logger = require('embark-logger');
|
||||
const DebugLog = require('embark-structlog');
|
||||
|
||||
class Engine {
|
||||
constructor(options) {
|
||||
|
@ -30,12 +30,15 @@ class Engine {
|
|||
const Events = require('./events.js');
|
||||
const Config = require('./config.js');
|
||||
|
||||
let options = _options || {};
|
||||
this.events = options.events || this.events || new Events();
|
||||
this.logger = options.logger || new Logger({context: this.context, logLevel: options.logLevel || this.logLevel || 'info', events: this.events, logFile: this.logFile});
|
||||
this.logger.startSession();
|
||||
this.debugLog = new DebugLog("embark");
|
||||
// TODO: only start if there is a flag doing so
|
||||
this.debugLog.startSession();
|
||||
|
||||
this.config = new Config({env: this.env, logger: this.logger, events: this.events, context: this.context, webServerConfig: this.webServerConfig, version: this.version});
|
||||
let options = _options || {};
|
||||
this.events = options.events || this.events || new Events({debugLog: this.debugLog});
|
||||
this.logger = options.logger || new Logger({context: this.context, logLevel: options.logLevel || this.logLevel || 'info', events: this.events, logFile: this.logFile});
|
||||
|
||||
this.config = new Config({env: this.env, logger: this.logger, debugLog: this.debugLog, events: this.events, context: this.context, webServerConfig: this.webServerConfig, version: this.version});
|
||||
this.config.loadConfigFiles({embarkConfig: this.embarkConfig, interceptLogs: this.interceptLogs});
|
||||
this.plugins = this.config.plugins;
|
||||
this.isDev = this.config && this.config.blockchainConfig && (this.config.blockchainConfig.isDev || this.config.blockchainConfig.default);
|
||||
|
|
|
@ -52,6 +52,13 @@ function log(eventType, eventName, origin) {
|
|||
|
||||
class EmbarkEmitter extends EventEmitter {
|
||||
|
||||
constructor(options) {
|
||||
super();
|
||||
if (options) {
|
||||
this.debugLog = options.debugLog;
|
||||
}
|
||||
}
|
||||
|
||||
emit(requestName, ...args) {
|
||||
warnIfLegacy(arguments[0]);
|
||||
// log("\n|event", requestName);
|
||||
|
@ -102,17 +109,12 @@ EmbarkEmitter.prototype.request2 = function() {
|
|||
let requestName = arguments[0];
|
||||
let other_args = [].slice.call(arguments, 1);
|
||||
|
||||
let requestId;
|
||||
if (this.logger && this.logId) {
|
||||
requestId = this.logger.log({parent_id: this.logId, type: "request", name: requestName, inputs: other_args})
|
||||
}
|
||||
let requestId = this.debugLog.log({parent_id: this.logId, type: "request", name: requestName, inputs: other_args});
|
||||
|
||||
log("\nREQUEST", requestName);
|
||||
warnIfLegacy(requestName);
|
||||
if (this._events && !this._events['request:' + requestName]) {
|
||||
if (this.logger && this.logId) {
|
||||
this.logger.log({id: requestId, error: "no request listener for " + requestName})
|
||||
}
|
||||
this.debugLog.log({id: requestId, error: "no request listener for " + requestName})
|
||||
log("NO REQUEST LISTENER", requestName);
|
||||
|
||||
if (debugEventsEnabled()) {
|
||||
|
@ -125,20 +127,14 @@ EmbarkEmitter.prototype.request2 = function() {
|
|||
other_args.push(
|
||||
(err, ...res) => {
|
||||
if (err) {
|
||||
if (this.logger && this.logId) {
|
||||
this.logger.log({id: requestId, msg: err, error: true})
|
||||
}
|
||||
this.debugLog.log({id: requestId, msg: err, error: true})
|
||||
return reject(err);
|
||||
}
|
||||
if (res.length && res.length > 1) {
|
||||
if (this.logger && this.logId) {
|
||||
this.logger.log({id: requestId, outputs: res})
|
||||
}
|
||||
this.debugLog.log({id: requestId, outputs: res})
|
||||
return resolve(res);
|
||||
}
|
||||
if (this.logger && this.logId) {
|
||||
this.logger.log({id: requestId, outputs: res[0]})
|
||||
}
|
||||
this.debugLog.log({id: requestId, outputs: res[0]})
|
||||
return resolve(res[0]);
|
||||
}
|
||||
);
|
||||
|
@ -154,9 +150,7 @@ EmbarkEmitter.prototype.request2 = function() {
|
|||
console.dir(ogStack);
|
||||
}
|
||||
|
||||
if (this.logger && this.logId) {
|
||||
this.logger.log({id: requestId, error: "promise exception", stack: ogStack})
|
||||
}
|
||||
this.debugLog.log({id: requestId, error: "promise exception", stack: ogStack})
|
||||
log("\n======== Exception ========", requestName, "\n " + ogStack + "\n==============");
|
||||
return e;
|
||||
});
|
||||
|
@ -168,17 +162,12 @@ EmbarkEmitter.prototype.request = function() {
|
|||
let requestName = arguments[0];
|
||||
let other_args = [].slice.call(arguments, 1);
|
||||
|
||||
let requestId;
|
||||
if (this.logger && this.logId) {
|
||||
requestId = this.logger.log({parent_id: this.logId, type: "old_request", name: requestName, inputs: other_args})
|
||||
}
|
||||
let requestId = this.debugLog.log({parent_id: this.logId, type: "old_request", name: requestName, inputs: other_args})
|
||||
|
||||
log("\nREQUEST(OLD)", requestName);
|
||||
warnIfLegacy(requestName);
|
||||
if (this._events && !this._events['request:' + requestName]) {
|
||||
if (this.logger && this.logId) {
|
||||
this.logger.log({id: requestId, error: "no request listener for " + requestName})
|
||||
}
|
||||
this.debugLog.log({id: requestId, error: "no request listener for " + requestName})
|
||||
log("NO REQUEST LISTENER", requestName);
|
||||
if (debugEventsEnabled()) {
|
||||
console.log("made request without listener: " + requestName);
|
||||
|
@ -207,19 +196,14 @@ EmbarkEmitter.prototype.request = function() {
|
|||
EmbarkEmitter.prototype.setCommandHandler = function(requestName, cb) {
|
||||
log("SET COMMAND HANDLER", requestName);
|
||||
|
||||
let requestId;
|
||||
if (this.logger && this.logId) {
|
||||
requestId = this.logger.log({parent_id: this.logId, type: "setCommandHandler", name: requestName})
|
||||
}
|
||||
let requestId = this.debugLog.log({parent_id: this.logId, type: "setCommandHandler", name: requestName})
|
||||
|
||||
// let origin = ((new Error().stack).split("at ")[3]).trim();
|
||||
// origin = origin.split("(")[0].trim();
|
||||
let origin = getOrigin();
|
||||
|
||||
let listener = function(_cb) {
|
||||
if (this.logger && this.logId) {
|
||||
this.logger.log({id: requestId, output: origin, source: origin});
|
||||
}
|
||||
this.debugLog.log({id: requestId, output: origin, source: origin});
|
||||
log("== REQUEST RESPONSE", requestName, origin);
|
||||
cb.call(this, ...arguments);
|
||||
};
|
||||
|
|
|
@ -50,6 +50,7 @@ var Plugin = function(options) {
|
|||
this.version = options.version;
|
||||
this.constants = constants;
|
||||
this.logId = options.logId;
|
||||
this.debugLog = options.debugLog;
|
||||
|
||||
if (!Array.isArray(this.currentContext)) {
|
||||
this.currentContext = [this.currentContext];
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import { dappPath, embarkPath } from 'embark-utils';
|
||||
|
||||
const async = require('async');
|
||||
var Plugin = require('./plugin.js');
|
||||
var fs = require('../core/fs.js');
|
||||
|
@ -9,6 +10,7 @@ var Plugins = function(options) {
|
|||
this.plugins = [];
|
||||
// TODO: need backup 'NullLogger'
|
||||
this.logger = options.logger;
|
||||
this.debugLog = options.debugLog;
|
||||
this.events = options.events;
|
||||
this.config = options.config;
|
||||
this.context = options.context;
|
||||
|
@ -51,6 +53,7 @@ Plugins.prototype.createPlugin = function(pluginName, pluginConfig) {
|
|||
pluginModule: plugin,
|
||||
pluginConfig: pluginConfig,
|
||||
logger: this.logger,
|
||||
debugLog: this.debugLog,
|
||||
pluginPath: pluginPath,
|
||||
interceptLogs: this.interceptLogs,
|
||||
events: this.events,
|
||||
|
@ -78,8 +81,8 @@ Plugins.prototype.loadInternalPlugin = function(pluginName, pluginConfig, isPack
|
|||
plugin = plugin.default;
|
||||
}
|
||||
|
||||
let logId = this.logger.moduleInit(pluginName);
|
||||
let events = Object.assign({}, this.events, {logId: logId, logger: this.logger});
|
||||
let logId = this.debugLog.moduleInit(pluginName);
|
||||
let events = Object.assign({}, this.events, {logId: logId, debugLog: this.debugLog});
|
||||
Object.setPrototypeOf(events, this.events);
|
||||
|
||||
const pluginWrapper = new Plugin({
|
||||
|
@ -87,6 +90,7 @@ Plugins.prototype.loadInternalPlugin = function(pluginName, pluginConfig, isPack
|
|||
pluginModule: plugin,
|
||||
pluginConfig: pluginConfig || {},
|
||||
logger: this.logger,
|
||||
debugLog: this.debugLog,
|
||||
logId: logId,
|
||||
pluginPath: pluginPath,
|
||||
interceptLogs: this.interceptLogs,
|
||||
|
@ -223,7 +227,7 @@ Plugins.prototype.runActionsForEvent = function(eventName, args, cb, logId) {
|
|||
return cb(null, args);
|
||||
}
|
||||
|
||||
this.logger.log({parent_id: logId, type: "trigger_action", name: eventName, source: this.events.getOrigin(true), givenLogId: logId, plugins: actionPlugins, inputs: args});
|
||||
this.debugLog.log({parent_id: logId, type: "trigger_action", name: eventName, source: this.events.getOrigin(true), givenLogId: logId, plugins: actionPlugins, inputs: args});
|
||||
|
||||
this.events.log("ACTION", eventName, "");
|
||||
|
||||
|
@ -231,16 +235,16 @@ Plugins.prototype.runActionsForEvent = function(eventName, args, cb, logId) {
|
|||
const [plugin, pluginName] = pluginObj;
|
||||
|
||||
self.events.log("== ACTION FOR " + eventName, plugin.name, pluginName);
|
||||
let actionLogId = self.logger.log({module: pluginName, type: "action_run", name: (eventName + plugin.name), source: pluginName, inputs: current_args});
|
||||
let actionLogId = self.debugLog.log({module: pluginName, type: "action_run", name: (eventName + plugin.name), source: pluginName, inputs: current_args});
|
||||
|
||||
if (typeof (args) === 'function') {
|
||||
plugin.call(plugin, (...params) => {
|
||||
self.logger.log({id: actionLogId, outputs: params || current_args});
|
||||
self.debugLog.log({id: actionLogId, outputs: params || current_args});
|
||||
return nextEach(...params || current_args);
|
||||
});
|
||||
} else {
|
||||
plugin.call(plugin, args, (...params) => {
|
||||
self.logger.log({id: actionLogId, outputs: (args, params || current_args)});
|
||||
self.debugLog.log({id: actionLogId, outputs: (args, params || current_args)});
|
||||
return nextEach(...params || current_args);
|
||||
});
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
let version = require('../../package.json').version;
|
||||
const Logger = require('embark-logger');
|
||||
|
||||
// TODO: remove this file??
|
||||
class Embark {
|
||||
|
||||
constructor(options) {
|
||||
|
|
|
@ -5,7 +5,8 @@ class ContractDeployer {
|
|||
// this.events = options.events;
|
||||
|
||||
this.logger = options.logger;
|
||||
this.logId = this.logger.moduleInit("ContractDeployer");
|
||||
this.debugLog = options.debugLog;
|
||||
this.logId = this.debugLog.moduleInit("ContractDeployer");
|
||||
|
||||
this.events = Object.assign({}, options.events, {logId: this.logId, logger: this.logger});
|
||||
Object.setPrototypeOf(this.events, options.events);
|
||||
|
@ -20,7 +21,7 @@ class ContractDeployer {
|
|||
}
|
||||
|
||||
deployContract(contract, callback) {
|
||||
let subId = this.logger.log({parent_id: this.logId, type: "method", name: "deployContract", inputs: {contract, callback}});
|
||||
let subId = this.debugLog.log({parent_id: this.logId, type: "method", name: "deployContract", inputs: {contract, callback}});
|
||||
async.waterfall([
|
||||
(next) => {
|
||||
this.plugins.emitAndRunActionsForEvent('deployment:contract:beforeDeploy', {contract: contract}, (err, _params) => {
|
||||
|
|
|
@ -12,6 +12,7 @@ class Deployment {
|
|||
this.logger = embark.logger;
|
||||
this.events = embark.events;
|
||||
this.logId = embark.logId;
|
||||
this.debugLog = embark.debugLog;
|
||||
|
||||
// this.events = Object.assign({}, embark.events, {logId: this.logId, logger: this.logger});
|
||||
// Object.setPrototypeOf(this.events, embark.events);
|
||||
|
@ -22,7 +23,8 @@ class Deployment {
|
|||
this.contractDeployer = new ContractDeployer({
|
||||
events: this.events,
|
||||
plugins: this.plugins,
|
||||
logger: this.logger
|
||||
logger: this.logger,
|
||||
debugLog: this.debugLog
|
||||
});
|
||||
|
||||
this.events.setCommandHandler('deployment:contracts:deploy', (contractsList, contractDependencies, cb) => {
|
||||
|
@ -31,7 +33,7 @@ class Deployment {
|
|||
}
|
||||
|
||||
deployContracts(contracts, contractDependencies, done) {
|
||||
let subId = this.logger.log({parent_id: this.logId, type: "method", name: "deployContracts", inputs: {contracts, contractDependencies}});
|
||||
let subId = this.debugLog.log({parent_id: this.logId, type: "method", name: "deployContracts", inputs: {contracts, contractDependencies}});
|
||||
|
||||
this.logger.info(__("deploying contracts"));
|
||||
async.waterfall([
|
||||
|
@ -53,7 +55,7 @@ class Deployment {
|
|||
}
|
||||
|
||||
deployContract(contract, callback) {
|
||||
let subId = this.logger.log({parent_id: this.logId, type: "method", name: "deployContract", inputs: {contract}});
|
||||
let subId = this.debugLog.log({parent_id: this.logId, type: "method", name: "deployContract", inputs: {contract}});
|
||||
this.events.request('deployment:contract:deploy', contract, (err) => {
|
||||
if (err) {
|
||||
contract.error = err.message || err;
|
||||
|
@ -62,16 +64,16 @@ class Deployment {
|
|||
} else {
|
||||
this.logger.error(`[${contract.className}]: ${err.message || err}`);
|
||||
}
|
||||
this.logger.log({id: subId, outputs: err, error: true});
|
||||
this.debugLog.log({id: subId, outputs: err, error: true});
|
||||
return callback(err);
|
||||
}
|
||||
this.logger.log({id: subId, outputs: ""});
|
||||
this.debugLog.log({id: subId, outputs: ""});
|
||||
callback();
|
||||
});
|
||||
}
|
||||
|
||||
deployAll(contracts, contractDependencies, done) {
|
||||
let subId = this.logger.log({parent_id: this.logId, type: "method", name: "deployAll", inputs: {contracts, contractDependencies}});
|
||||
let subId = this.debugLog.log({parent_id: this.logId, type: "method", name: "deployAll", inputs: {contracts, contractDependencies}});
|
||||
const self = this;
|
||||
const contractDeploys = {};
|
||||
const errors = [];
|
||||
|
@ -113,16 +115,16 @@ class Deployment {
|
|||
if (errors.length) {
|
||||
err = __("Error deploying contracts. Please fix errors to continue.");
|
||||
|
||||
this.logger.log({id: subId, outputs: err, error: true});
|
||||
this.debugLog.log({id: subId, outputs: err, error: true});
|
||||
return done(err);
|
||||
}
|
||||
if (contracts.length === 0) {
|
||||
this.logger.info(__("no contracts found"));
|
||||
this.logger.log({id: subId, outputs: "", msg: "no contracts found"});
|
||||
this.debugLog.log({id: subId, outputs: "", msg: "no contracts found"});
|
||||
return done();
|
||||
}
|
||||
this.logger.info(__("finished deploying contracts"));
|
||||
this.logger.log({id: subId, outputs: err, error: !!err, msg: "finished deploying contracts"});
|
||||
this.debugLog.log({id: subId, outputs: err, error: !!err, msg: "finished deploying contracts"});
|
||||
done(err);
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue