*Add log and log error to instance
This commit is contained in:
parent
784787de87
commit
0611634adf
16
src/index.ts
16
src/index.ts
|
@ -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);
|
||||
|
||||
|
|
Reference in New Issue