mirror of
https://github.com/fluencelabs/fluence-js.git
synced 2025-06-30 00:01:35 +00:00
Add logging for particle receive events (#13)
* Add logging for particle receive events * Better log levels
This commit is contained in:
@ -221,12 +221,17 @@ export class FluenceClientImpl extends FluenceClientBase implements FluenceClien
|
|||||||
executingParticle.reject(new Error(`particle ${particle.id} timed out`));
|
executingParticle.reject(new Error(`particle ${particle.id} timed out`));
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onLocalParticleRecieved: (particle: ParticleDto) => {},
|
onLocalParticleRecieved: (particle: ParticleDto) => {
|
||||||
onExternalParticleRecieved: (particle: ParticleDto) => {},
|
log.debug('local particle received', particle);
|
||||||
onStepperExecuting: (particle: ParticleDto) => {},
|
},
|
||||||
|
onExternalParticleRecieved: (particle: ParticleDto) => {
|
||||||
|
log.debug('external particle received', particle);
|
||||||
|
},
|
||||||
|
onStepperExecuting: (particle: ParticleDto) => {
|
||||||
|
log.debug('stepper executing particle', particle);
|
||||||
|
},
|
||||||
onStepperExecuted: (stepperOutcome: StepperOutcome) => {
|
onStepperExecuted: (stepperOutcome: StepperOutcome) => {
|
||||||
log.info('inner interpreter outcome:');
|
log.debug('inner interpreter outcome:', stepperOutcome);
|
||||||
log.info(stepperOutcome);
|
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -81,7 +81,7 @@ export class FluenceConnection {
|
|||||||
if (this.status === Status.Initializing) {
|
if (this.status === Status.Initializing) {
|
||||||
await this.node.start();
|
await this.node.start();
|
||||||
|
|
||||||
log.debug(`dialing to the node with client's address: ` + this.node.peerId.toB58String());
|
log.trace(`dialing to the node with client's address: ` + this.node.peerId.toB58String());
|
||||||
|
|
||||||
await this.node.dial(this.address);
|
await this.node.dial(this.address);
|
||||||
|
|
||||||
@ -92,8 +92,7 @@ export class FluenceConnection {
|
|||||||
for await (const msg of source) {
|
for await (const msg of source) {
|
||||||
try {
|
try {
|
||||||
let particle = parseParticle(msg);
|
let particle = parseParticle(msg);
|
||||||
log.debug('Particle is received:');
|
log.trace('Particle is received:', JSON.stringify(particle, undefined, 2));
|
||||||
log.debug(JSON.stringify(particle, undefined, 2));
|
|
||||||
_this.handleParticle(particle);
|
_this.handleParticle(particle);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
log.error('error on handling a new incoming message: ' + e);
|
log.error('error on handling a new incoming message: ' + e);
|
||||||
|
@ -26,10 +26,10 @@ let magicParticleStorage: Map<string, Map<string, any>> = new Map();
|
|||||||
|
|
||||||
// HACK:: make an api for aqua stepper to accept variables in an easy way!
|
// HACK:: make an api for aqua stepper to accept variables in an easy way!
|
||||||
export function injectDataIntoParticle(particleId: string, data: Map<string, any>, ttl: number) {
|
export function injectDataIntoParticle(particleId: string, data: Map<string, any>, ttl: number) {
|
||||||
log.debug(`setting data for ${particleId}`, data);
|
log.trace(`setting data for ${particleId}`, data);
|
||||||
magicParticleStorage.set(particleId, data);
|
magicParticleStorage.set(particleId, data);
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
log.debug(`data for ${particleId} is deleted`);
|
log.trace(`data for ${particleId} is deleted`);
|
||||||
magicParticleStorage.delete(particleId);
|
magicParticleStorage.delete(particleId);
|
||||||
}, ttl);
|
}, ttl);
|
||||||
}
|
}
|
||||||
@ -215,11 +215,8 @@ export class ParticleProcessor {
|
|||||||
let data: any = particle.data;
|
let data: any = particle.data;
|
||||||
let error: any = data['protocol!error'];
|
let error: any = data['protocol!error'];
|
||||||
if (error !== undefined) {
|
if (error !== undefined) {
|
||||||
log.error('error in external particle: ');
|
log.error('error in external particle: ', error);
|
||||||
log.error(error);
|
|
||||||
} else {
|
} else {
|
||||||
log.info('handle external particle: ');
|
|
||||||
log.info(particle);
|
|
||||||
await this.handleParticle(particle);
|
await this.handleParticle(particle);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user