dont show all 20 send messages
support muting a logger and chaining callspull/21833/head
parent
dcf96e1461
commit
244d5b0851
|
@ -111,8 +111,11 @@ async function aLazyLoadingTest(alice, bob, charlies) {
|
||||||
await bob.delay(500);
|
await bob.delay(500);
|
||||||
await charlies.join(alias);
|
await charlies.join(alias);
|
||||||
const messageRange = range(1, 20);
|
const messageRange = range(1, 20);
|
||||||
|
bob.log.step("sends 20 messages").mute();
|
||||||
for(let i = 20; i >= 1; --i) {
|
for(let i = 20; i >= 1; --i) {
|
||||||
await sendMessage(bob, `I will only say this ${i} time(s)!`);
|
await sendMessage(bob, `I will only say this ${i} time(s)!`);
|
||||||
}
|
}
|
||||||
|
bob.log.unmute().done();
|
||||||
await join(alice, room);
|
await join(alice, room);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,25 +35,46 @@ class Logger {
|
||||||
constructor(username) {
|
constructor(username) {
|
||||||
this.indent = 0;
|
this.indent = 0;
|
||||||
this.username = username;
|
this.username = username;
|
||||||
|
this.muted = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
startGroup(description) {
|
startGroup(description) {
|
||||||
const indent = " ".repeat(this.indent * 2);
|
if (!this.muted) {
|
||||||
console.log(`${indent} * ${this.username} ${description}:`);
|
const indent = " ".repeat(this.indent * 2);
|
||||||
|
console.log(`${indent} * ${this.username} ${description}:`);
|
||||||
|
}
|
||||||
this.indent += 1;
|
this.indent += 1;
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
endGroup() {
|
endGroup() {
|
||||||
this.indent -= 1;
|
this.indent -= 1;
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
step(description) {
|
step(description) {
|
||||||
const indent = " ".repeat(this.indent * 2);
|
if (!this.muted) {
|
||||||
process.stdout.write(`${indent} * ${this.username} ${description} ... `);
|
const indent = " ".repeat(this.indent * 2);
|
||||||
|
process.stdout.write(`${indent} * ${this.username} ${description} ... `);
|
||||||
|
}
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
done(status = "done") {
|
done(status = "done") {
|
||||||
process.stdout.write(status + "\n");
|
if (!this.muted) {
|
||||||
|
process.stdout.write(status + "\n");
|
||||||
|
}
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
mute() {
|
||||||
|
this.muted = true;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
unmute() {
|
||||||
|
this.muted = false;
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue