git.delta.rocks / unique-network / refs/commits / fc68cba5bed8

difftreelog

Remove logs from the console

Yaroslav Bolyukin2022-08-31parent: #21a2ff1.patch.diff
in: master

3 files changed

modifiedtests/src/substrate/substrate-api.tsdiffbeforeafterboth
--- a/tests/src/substrate/substrate-api.ts
+++ b/tests/src/substrate/substrate-api.ts
@@ -85,7 +85,7 @@
     for (const arg of args) {
       if (typeof arg !== 'string')
         continue;
-      if (arg.includes('1000:: Normal connection closure' || arg === 'Normal connection closure'))
+      if (arg.includes('1000:: Normal connection closure') || arg.includes('Not decorating unknown runtime apis:') || arg.includes('RPC methods not decorated:') || arg === 'Normal connection closure')
         return;
     }
     printer(...args);
modifiedtests/src/util/playgrounds/index.tsdiffbeforeafterboth
before · tests/src/util/playgrounds/index.ts
1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.2// SPDX-License-Identifier: Apache-2.034import {IKeyringPair} from '@polkadot/types/types';5import config from '../../config';6import '../../interfaces/augment-api-events';7import {DevUniqueHelper} from './unique.dev';89class SilentLogger {10  log(msg: any, level: any): void { }11  level = {12    ERROR: 'ERROR' as const,13    WARNING: 'WARNING' as const,14    INFO: 'INFO' as const,15  };16}1718export const usingPlaygrounds = async (code: (helper: DevUniqueHelper, privateKey: (seed: string) => IKeyringPair) => Promise<void>) => {19  // TODO: Remove, this is temporary: Filter unneeded API output20  // (Jaco promised it will be removed in the next version)21  const consoleErr = console.error;22  const consoleLog = console.log;23  const consoleWarn = console.warn;2425  const outFn = (printer: any) => (...args: any[]) => {26    for (const arg of args) {27      if (typeof arg !== 'string')28        continue;29      if (arg.includes('1000:: Normal connection closure' || arg === 'Normal connection closure'))30        return;31    }32    printer(...args);33  };3435  console.error = outFn(consoleErr.bind(console));36  console.log = outFn(consoleLog.bind(console));37  console.warn = outFn(consoleWarn.bind(console));38  const helper = new DevUniqueHelper(new SilentLogger());3940  try {41    await helper.connect(config.substrateUrl);42    const ss58Format = helper.chain.getChainProperties().ss58Format;43    const privateKey = (seed: string) => helper.util.fromSeed(seed, ss58Format);44    await code(helper, privateKey);45  }46  finally {47    await helper.disconnect();48    console.error = consoleErr;49    console.log = consoleLog;50    console.warn = consoleWarn;51  }52};
after · tests/src/util/playgrounds/index.ts
1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.2// SPDX-License-Identifier: Apache-2.034import {IKeyringPair} from '@polkadot/types/types';5import config from '../../config';6import '../../interfaces/augment-api-events';7import {DevUniqueHelper} from './unique.dev';89class SilentLogger {10  log(msg: any, level: any): void { }11  level = {12    ERROR: 'ERROR' as const,13    WARNING: 'WARNING' as const,14    INFO: 'INFO' as const,15  };16}1718export const usingPlaygrounds = async (code: (helper: DevUniqueHelper, privateKey: (seed: string) => IKeyringPair) => Promise<void>) => {19  // TODO: Remove, this is temporary: Filter unneeded API output20  // (Jaco promised it will be removed in the next version)21  const consoleErr = console.error;22  const consoleLog = console.log;23  const consoleWarn = console.warn;2425  const outFn = (printer: any) => (...args: any[]) => {26    for (const arg of args) {27      if (typeof arg !== 'string')28        continue;29      if (arg.includes('1000:: Normal connection closure') || arg.includes('Not decorating unknown runtime apis:') || arg.includes('RPC methods not decorated:') || arg === 'Normal connection closure')30        return;31    }32    printer(...args);33  };3435  console.error = outFn(consoleErr.bind(console));36  console.log = outFn(consoleLog.bind(console));37  console.warn = outFn(consoleWarn.bind(console));38  const helper = new DevUniqueHelper(new SilentLogger());3940  try {41    await helper.connect(config.substrateUrl);42    const ss58Format = helper.chain.getChainProperties().ss58Format;43    const privateKey = (seed: string) => helper.util.fromSeed(seed, ss58Format);44    await code(helper, privateKey);45  }46  finally {47    await helper.disconnect();48    console.error = consoleErr;49    console.log = consoleLog;50    console.warn = consoleWarn;51  }52};
modifiedtests/src/util/playgrounds/unique.dev.tsdiffbeforeafterboth
--- a/tests/src/util/playgrounds/unique.dev.ts
+++ b/tests/src/util/playgrounds/unique.dev.ts
@@ -103,7 +103,6 @@
     let accountsCreated = false;
     // checkBalances retry up to 5 blocks
     for (let index = 0; index < 5; index++) {
-      console.log(await this.helper.chain.getLatestBlockNumber());
       accountsCreated = await checkBalances();
       if(accountsCreated) break;
       await this.waitNewBlocks(1);