diff options
author | Leonid Logvinov <logvinov.leon@gmail.com> | 2018-05-23 01:39:27 +0800 |
---|---|---|
committer | Leonid Logvinov <logvinov.leon@gmail.com> | 2018-05-23 06:26:29 +0800 |
commit | ac52ad88a1884979c74f418398bbf428d727cf34 (patch) | |
tree | c4d75f369edd147797ae866529973d210a672c78 /packages/sol-cov | |
parent | 84a1b5612de3b22bbe6b8b01a997234771d98005 (diff) | |
download | dexon-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')
-rw-r--r-- | packages/sol-cov/package.json | 8 | ||||
-rw-r--r-- | packages/sol-cov/src/coverage_manager.ts | 18 |
2 files changed, 12 insertions, 14 deletions
diff --git a/packages/sol-cov/package.json b/packages/sol-cov/package.json index e4d8c6da8..0edffb1d2 100644 --- a/packages/sol-cov/package.json +++ b/packages/sol-cov/package.json @@ -46,17 +46,18 @@ }, "homepage": "https://github.com/0xProject/0x.js/packages/sol-cov/README.md", "dependencies": { + "@0xproject/sol-compiler": "^0.4.3", "@0xproject/subproviders": "^0.10.2", "@0xproject/types": "^0.7.0", "@0xproject/typescript-typings": "^0.3.2", "@0xproject/utils": "^0.6.2", - "@0xproject/sol-compiler": "^0.4.3", "ethereumjs-util": "^5.1.1", - "rimraf": "^2.6.2", "glob": "^7.1.2", "istanbul": "^0.4.5", "lodash": "^4.17.4", + "loglevel": "^1.6.1", "mkdirp": "^0.5.1", + "rimraf": "^2.6.2", "semaphore-async-await": "^1.5.1", "solidity-parser-antlr": "^0.2.8" }, @@ -64,10 +65,11 @@ "@0xproject/monorepo-scripts": "^0.1.20", "@0xproject/tslint-config": "^0.4.18", "@types/istanbul": "^0.4.30", - "@types/rimraf": "^2.0.2", + "@types/loglevel": "^1.5.3", "@types/mkdirp": "^0.5.1", "@types/mocha": "^2.2.42", "@types/node": "^8.0.53", + "@types/rimraf": "^2.0.2", "chai": "^4.0.1", "copyfiles": "^1.2.0", "dirty-chai": "^2.0.1", 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); |