aboutsummaryrefslogtreecommitdiffstats
path: root/packages/sol-cov/src
diff options
context:
space:
mode:
authorLeonid Logvinov <logvinov.leon@gmail.com>2018-05-23 01:39:27 +0800
committerLeonid Logvinov <logvinov.leon@gmail.com>2018-05-23 06:26:29 +0800
commitac52ad88a1884979c74f418398bbf428d727cf34 (patch)
treec4d75f369edd147797ae866529973d210a672c78 /packages/sol-cov/src
parent84a1b5612de3b22bbe6b8b01a997234771d98005 (diff)
downloaddexon-sol-tools-ac52ad88a1884979c74f418398bbf428d727cf34.tar
dexon-sol-tools-ac52ad88a1884979c74f418398bbf428d727cf34.tar.gz
dexon-sol-tools-ac52ad88a1884979c74f418398bbf428d727cf34.tar.bz2
dexon-sol-tools-ac52ad88a1884979c74f418398bbf428d727cf34.tar.lz
dexon-sol-tools-ac52ad88a1884979c74f418398bbf428d727cf34.tar.xz
dexon-sol-tools-ac52ad88a1884979c74f418398bbf428d727cf34.tar.zst
dexon-sol-tools-ac52ad88a1884979c74f418398bbf428d727cf34.zip
Use loglevel instead of verbose flag
Diffstat (limited to 'packages/sol-cov/src')
-rw-r--r--packages/sol-cov/src/coverage_manager.ts18
1 files changed, 7 insertions, 11 deletions
diff --git a/packages/sol-cov/src/coverage_manager.ts b/packages/sol-cov/src/coverage_manager.ts
index d7a00f86d..3aa62acff 100644
--- a/packages/sol-cov/src/coverage_manager.ts
+++ b/packages/sol-cov/src/coverage_manager.ts
@@ -3,6 +3,7 @@ import { addHexPrefix, stripHexPrefix } from 'ethereumjs-util';
import * as fs from 'fs';
import { Collector } from 'istanbul';
import * as _ from 'lodash';
+import { getLogger, levels, Logger, LogLevel } from 'loglevel';
import * as mkdirp from 'mkdirp';
import * as path from 'path';
@@ -35,7 +36,7 @@ const mkdirpAsync = promisify<undefined>(mkdirp);
export class CoverageManager {
private _artifactAdapter: AbstractArtifactAdapter;
- private _verbose: boolean;
+ private _logger: Logger;
private _traceInfos: TraceInfo[] = [];
private _getContractCodeAsync: (address: string) => Promise<string>;
private static _getSingleFileCoverageForTrace(
@@ -124,7 +125,7 @@ export class CoverageManager {
}
private static _getContractDataIfExists(contractsData: ContractData[], bytecode: string): ContractData | undefined {
if (!bytecode.startsWith('0x')) {
- throw new Error(')x missing');
+ throw new Error('0x missing');
}
const contractData = _.find(contractsData, contractDataCandidate => {
const bytecodeRegex = CoverageManager._bytecodeToBytecodeRegex(contractDataCandidate.bytecode);
@@ -142,7 +143,8 @@ export class CoverageManager {
) {
this._getContractCodeAsync = getContractCodeAsync;
this._artifactAdapter = artifactAdapter;
- this._verbose = verbose;
+ this._logger = getLogger('sol-cov');
+ this._logger.setLevel(verbose ? levels.TRACE : levels.ERROR);
}
public appendTraceInfo(traceInfo: TraceInfo): void {
this._traceInfos.push(traceInfo);
@@ -162,10 +164,7 @@ export class CoverageManager {
const runtimeBytecode = (traceInfo as TraceInfoExistingContract).runtimeBytecode;
const contractData = CoverageManager._getContractDataIfExists(contractsData, runtimeBytecode);
if (_.isUndefined(contractData)) {
- if (this._verbose) {
- // tslint:disable-next-line:no-console
- console.warn(`Transaction to an unknown address: ${traceInfo.address}`);
- }
+ this._logger.warn(`Transaction to an unknown address: ${traceInfo.address}`);
continue;
}
const bytecodeHex = stripHexPrefix(runtimeBytecode);
@@ -190,10 +189,7 @@ export class CoverageManager {
const bytecode = (traceInfo as TraceInfoNewContract).bytecode;
const contractData = CoverageManager._getContractDataIfExists(contractsData, bytecode);
if (_.isUndefined(contractData)) {
- if (this._verbose) {
- // tslint:disable-next-line:no-console
- console.warn(`Unknown contract creation transaction`);
- }
+ this._logger.warn(`Unknown contract creation transaction`);
continue;
}
const bytecodeHex = stripHexPrefix(bytecode);