mirror of
https://github.com/embarklabs/embark.git
synced 2025-02-22 10:28:34 +00:00
extend logger
This commit is contained in:
parent
06a80f86c3
commit
340fbacdee
@ -89,7 +89,7 @@ export class Engine {
|
|||||||
this.debugLog.startSession();
|
this.debugLog.startSession();
|
||||||
|
|
||||||
this.events = options.events || this.events || new Events({debugLog: this.debugLog});
|
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.logger = options.logger || new Logger({context: this.context, debugLog: this.debugLog, 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, package: this.package});
|
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, package: this.package});
|
||||||
|
|
||||||
|
@ -10,6 +10,7 @@ const LOG_REGEX = new RegExp(/\[(\d\d\d\d-\d\d-\d\d \d\d:\d\d:\d\d:\d\d\d)\] (?:
|
|||||||
export class Logger {
|
export class Logger {
|
||||||
constructor(options) {
|
constructor(options) {
|
||||||
this.events = options.events || {emit: function(){}};
|
this.events = options.events || {emit: function(){}};
|
||||||
|
this.debugLog = options.debugLog;
|
||||||
this.logLevels = Object.keys(Logger.logLevels);
|
this.logLevels = Object.keys(Logger.logLevels);
|
||||||
this.logLevel = options.logLevel || 'info';
|
this.logLevel = options.logLevel || 'info';
|
||||||
this._logFunction = options.logFunction || console.log;
|
this._logFunction = options.logFunction || console.log;
|
||||||
@ -91,7 +92,11 @@ Logger.prototype.registerAPICall = function (plugins) {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
Logger.prototype.writeToFile = function (_txt) {
|
Logger.prototype.writeToFile = function (txt) {
|
||||||
|
if (this.debugLog) {
|
||||||
|
this.debugLog.log({parent_id: this.logId, type: "log_info", name: txt});
|
||||||
|
}
|
||||||
|
|
||||||
if (!this.logFile) {
|
if (!this.logFile) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -157,6 +157,7 @@ class EmbarkController {
|
|||||||
|
|
||||||
let runId = engine.debugLog.moduleInit("run_command")
|
let runId = engine.debugLog.moduleInit("run_command")
|
||||||
engine.events = engine.debugLog.tagObject(engine.events, runId);
|
engine.events = engine.debugLog.tagObject(engine.events, runId);
|
||||||
|
engine.logger = engine.debugLog.tagObject(engine.logger, runId);
|
||||||
|
|
||||||
engine.registerModuleGroup("coreComponents");
|
engine.registerModuleGroup("coreComponents");
|
||||||
engine.registerModuleGroup("stackComponents");
|
engine.registerModuleGroup("stackComponents");
|
||||||
|
@ -83,12 +83,14 @@ Plugins.prototype.loadInternalPlugin = function(pluginName, pluginConfig, isPack
|
|||||||
|
|
||||||
let logId = this.debugLog.moduleInit(pluginName);
|
let logId = this.debugLog.moduleInit(pluginName);
|
||||||
let events = this.debugLog.tagObject(this.events, logId);
|
let events = this.debugLog.tagObject(this.events, logId);
|
||||||
|
let logger = this.debugLog.tagObject(this.logger, logId);
|
||||||
|
// let logger = this.logger;
|
||||||
|
|
||||||
const pluginWrapper = new Plugin({
|
const pluginWrapper = new Plugin({
|
||||||
name: pluginName,
|
name: pluginName,
|
||||||
pluginModule: plugin,
|
pluginModule: plugin,
|
||||||
pluginConfig: pluginConfig || {},
|
pluginConfig: pluginConfig || {},
|
||||||
logger: this.logger,
|
logger: logger,
|
||||||
debugLog: this.debugLog,
|
debugLog: this.debugLog,
|
||||||
logId: logId,
|
logId: logId,
|
||||||
pluginPath: pluginPath,
|
pluginPath: pluginPath,
|
||||||
|
@ -4,10 +4,10 @@ class ContractDeployer {
|
|||||||
constructor(options) {
|
constructor(options) {
|
||||||
// this.events = options.events;
|
// this.events = options.events;
|
||||||
|
|
||||||
this.logger = options.logger;
|
|
||||||
this.debugLog = options.debugLog;
|
this.debugLog = options.debugLog;
|
||||||
this.logId = this.debugLog.moduleInit("ContractDeployer");
|
this.logId = this.debugLog.moduleInit("ContractDeployer");
|
||||||
this.events = this.debugLog.tagObject(options.events, this.logId);
|
this.events = this.debugLog.tagObject(options.events, this.logId);
|
||||||
|
this.logger = this.debugLog.tagObject(options.logger, this.logId);
|
||||||
|
|
||||||
this.plugins = options.plugins;
|
this.plugins = options.plugins;
|
||||||
this.deployer = {};
|
this.deployer = {};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user