Pass logging level to AVM (#158)

This commit is contained in:
Pavel
2022-07-07 12:52:32 +03:00
committed by GitHub
parent 2b752492c1
commit f0906066c5
3 changed files with 25 additions and 11 deletions

View File

@ -20,7 +20,7 @@ import { PeerIdB58 } from './commonTypes';
import { FluenceConnection } from './FluenceConnection';
import { Particle, ParticleExecutionStage, ParticleQueueItem } from './Particle';
import { KeyPair } from './KeyPair';
import { throwIfNotSupported, dataToString, jsonify } from './utils';
import { throwIfNotSupported, dataToString, jsonify, MarineLoglevel, marineLogLevelToEnvs } from './utils';
import { concatMap, filter, pipe, Subject, tap } from 'rxjs';
import log from 'loglevel';
import { builtInServices } from './builtins/common';
@ -40,12 +40,6 @@ type Node = {
multiaddr: string;
};
/**
* Enum representing the log level used in Aqua VM.
* Possible values: 'info', 'trace', 'debug', 'info', 'warn', 'error', 'off';
*/
export type MarineLoglevel = LogLevel;
const DEFAULT_TTL = 7000;
/**
@ -242,7 +236,12 @@ export class FluencePeer {
? await loadMarineAndAvm(config.marineJS.marineWasmPath, config.marineJS.avmWasmPath)
: await loadDefaults();
await this._fluenceAppService.init(marineDeps.marine);
await this._fluenceAppService.createService(marineDeps.avm, 'avm');
await this._fluenceAppService.createService(
marineDeps.avm,
'avm',
undefined,
marineLogLevelToEnvs(this._marineLogLevel),
);
this._avmRunner = config?.avmRunner || new AVM(this._fluenceAppService);
await this._avmRunner.init(config?.avmLogLevel || 'off');
@ -309,8 +308,12 @@ export class FluencePeer {
throw new Error(`Service with '${serviceId}' id already exists`);
}
const envs = this._marineLogLevel ? { WASM_LOG: this._marineLogLevel } : undefined;
await this._fluenceAppService.createService(wasm, serviceId, undefined, envs);
await this._fluenceAppService.createService(
wasm,
serviceId,
undefined,
marineLogLevelToEnvs(this._marineLogLevel),
);
this._marineServices.add(serviceId);
}