*Add log and log error to instance

This commit is contained in:
Derrick Hammer 2023-02-16 21:06:12 -05:00
parent 784787de87
commit 0611634adf
Signed by: pcfreak30
GPG Key ID: C997C339BE476FF2
1 changed files with 16 additions and 0 deletions

View File

@ -37,6 +37,18 @@ export abstract class Client extends EventEmitter {
return this._callModule as callModuleBound;
}
private _log?: log;
get log(): log {
return this._log as log;
}
private _logErr?: logErr;
get logErr(): logErr {
return this._logErr as logErr;
}
private _connectModule?: connectModuleBound;
get connectModule(): connectModuleBound {
@ -55,6 +67,8 @@ export abstract class Client extends EventEmitter {
return ret;
};
this._connectModule = moduleBag.connectModule;
this._log = log;
this._logErr = logErr;
}
public async loadBound(module: string): Promise<ModuleBagBound> {
@ -66,10 +80,12 @@ export abstract class Client extends EventEmitter {
throw new Error(ret[1]);
}
}
protected handleErrorOrReturn(ret: ErrTuple): any {
this.handleError(ret);
return ret[0];
}
protected async callModuleReturn(method: string, data?: any): Promise<any> {
const ret = await this.callModule(method, data);