diff --git a/_scripts/cache-issue.ts b/_scripts/cache-issue.ts index 9db31cb..5e66f45 100644 --- a/_scripts/cache-issue.ts +++ b/_scripts/cache-issue.ts @@ -24,7 +24,7 @@ async function main() { }); const swcClient = SwClientFactory.memCacheClient(arweave); - LoggerFactory.INST.logLevel('debug'); + LoggerFactory.INST.logLevel('trace'); const contractTxId = 'W_njBtwDRyltjVU1RizJtZfF0S_4X3aSrrrA0HUEhUs'; const contractTxId2 = 'TMkCZKYO3GwcTLEKGgWSJegIlYCHi_UArtG0unCi2xA'; diff --git a/_scripts/state-comparator.ts b/_scripts/state-comparator.ts index 227d13f..a82ddfb 100644 --- a/_scripts/state-comparator.ts +++ b/_scripts/state-comparator.ts @@ -215,7 +215,7 @@ async function main() { logger.info('skipping ', contractTxId); errorContractTxIds.push(contractTxId); } finally { - logger.debug('Contracts with different states: %o', differentStatesContractTxIds); + logger.debug('Contracts with different states:', differentStatesContractTxIds); logger.info('\n\n ==== END'); } } @@ -268,7 +268,7 @@ async function getNextPage(arweave, variables) { variables }); - logger.verbose('Status:', response.status); + logger.debug('Status:', response.status); if (response.status !== 200) { throw new Error('Wrong response from Ar GQL'); } diff --git a/_scripts/swc-stats.ts b/_scripts/swc-stats.ts index a971bee..33e01e3 100644 --- a/_scripts/swc-stats.ts +++ b/_scripts/swc-stats.ts @@ -113,7 +113,7 @@ async function main() { const sortedContracts = {}; sortable.forEach((item) => (sortedContracts[item[0]] = item[1])); - logger.debug('%o', sortedContracts); + logger.debug(sortedContracts); fs.writeFileSync(path.join(__dirname, `swc-sorted-stats.json`), JSON.stringify(sortedContracts)); } diff --git a/package.json b/package.json index 9cdf2d9..605f5ce 100644 --- a/package.json +++ b/package.json @@ -49,6 +49,7 @@ "bignumber.js": "^9.0.1", "bson": "^4.5.0", "json-beautify": "^1.1.1", + "tslog": "^3.2.1", "winston": "^3.3.3" }, "devDependencies": { diff --git a/src/cache/impl/BsonFileBlockHeightCache.ts b/src/cache/impl/BsonFileBlockHeightCache.ts index 019d66e..54da4df 100644 --- a/src/cache/impl/BsonFileBlockHeightCache.ts +++ b/src/cache/impl/BsonFileBlockHeightCache.ts @@ -91,7 +91,7 @@ export class BsonFileBlockHeightSwCache implements BlockHeightSwCache { const directory = key; diff --git a/src/client/HandlerBasedSwcClient.ts b/src/client/HandlerBasedSwcClient.ts index 6ecbd06..edfbd43 100644 --- a/src/client/HandlerBasedSwcClient.ts +++ b/src/client/HandlerBasedSwcClient.ts @@ -42,7 +42,7 @@ export class HandlerBasedSwcClient implements SwcClient { currentTx?: { interactionTxId: string; contractTxId: string }[], evaluationOptions?: EvaluationOptions ): Promise> { - logger.info('Read state for %s', contractTxId); + logger.info(`Read state for ${contractTxId}`); logger.profile('Creating execution context'); const executionContext = await this.createExecutionContext(contractTxId, blockHeight, evaluationOptions); logger.profile('Creating execution context'); @@ -62,7 +62,7 @@ export class HandlerBasedSwcClient implements SwcClient { blockHeight?: number, evaluationOptions?: EvaluationOptions ): Promise> { - logger.info('View state for %s', contractTxId); + logger.info(`View state for ${contractTxId}`); logger.profile('Creating execution context'); let executionContext = await this.createExecutionContext(contractTxId, blockHeight, evaluationOptions); logger.profile('Creating execution context'); @@ -121,7 +121,7 @@ export class HandlerBasedSwcClient implements SwcClient { transaction: InteractionTx, evaluationOptions?: EvaluationOptions ): Promise> { - logger.info('Vies state for %s %o', contractTxId, transaction); + logger.info(`Vies state for ${contractTxId}`, transaction); logger.profile('Creating execution context'); const executionContext = await this.createExecutionContextFromTx(contractTxId, transaction); logger.profile('Creating execution context'); diff --git a/src/core/impl/ContractDefinitionLoader.ts b/src/core/impl/ContractDefinitionLoader.ts index 596a2b9..8776a7d 100644 --- a/src/core/impl/ContractDefinitionLoader.ts +++ b/src/core/impl/ContractDefinitionLoader.ts @@ -13,7 +13,7 @@ export class ContractDefinitionLoader implements DefinitionLoader> { if (!forcedSrcTxId && this.cache?.contains(contractTxId)) { - logger.verbose('ContractDefinitionLoader: Hit from cache!'); + logger.debug('ContractDefinitionLoader: Hit from cache!'); return Promise.resolve(this.cache?.get(contractTxId)); } diff --git a/src/core/impl/ContractInteractionsLoader.ts b/src/core/impl/ContractInteractionsLoader.ts index 6dcb9f3..ea3f4cb 100644 --- a/src/core/impl/ContractInteractionsLoader.ts +++ b/src/core/impl/ContractInteractionsLoader.ts @@ -94,7 +94,7 @@ export class ContractInteractionsLoader implements InteractionsLoader { txInfos.push(...transactions.edges.filter((tx) => !tx.node.parent || !tx.node.parent.id)); } - logger.verbose('All interactions: %s', txInfos.length); + logger.debug('All interactions:', txInfos.length); return txInfos; } diff --git a/src/core/impl/DefaultStateEvaluator.ts b/src/core/impl/DefaultStateEvaluator.ts index 44d859b..4a075f2 100644 --- a/src/core/impl/DefaultStateEvaluator.ts +++ b/src/core/impl/DefaultStateEvaluator.ts @@ -47,14 +47,11 @@ export class DefaultStateEvaluator implements StateEvaluator implements ExecutorFactory implements ExecutorFactory> ) { swGlobal.contracts.viewContractState = async (contractTxId: string, input: any) => { - logger.verbose('swGlobal.viewContractState call: %o', { + logger.debug('swGlobal.viewContractState call:', { from: contractDefinition.txId, to: contractTxId, input @@ -116,7 +116,7 @@ export class HandlerExecutorFactory implements ExecutorFactory { - logger.verbose('swGlobal.readContractState call: ', { + logger.debug('swGlobal.readContractState call: ', { from: contractDefinition.txId, to: contractTxId, interaction diff --git a/src/plugins/CacheableContractInteractionsLoader.ts b/src/plugins/CacheableContractInteractionsLoader.ts index e9bc4df..a6c10ee 100644 --- a/src/plugins/CacheableContractInteractionsLoader.ts +++ b/src/plugins/CacheableContractInteractionsLoader.ts @@ -16,7 +16,7 @@ export class CacheableContractInteractionsLoader implements InteractionsLoader { ) {} async load(contractId: string, blockHeight: number): Promise { - logger.debug('Loading interactions %o', { + logger.debug('Loading interactions', { contractId, blockHeight }); @@ -24,7 +24,7 @@ export class CacheableContractInteractionsLoader implements InteractionsLoader { const cached = this.cache.get(contractId, blockHeight); if (cached !== null) { - logger.verbose('InteractionsLoader - hit from cache!'); + logger.debug('InteractionsLoader - hit from cache!'); return cached.cachedValue; } else { const result = await this.baseImplementation.load(contractId, blockHeight); diff --git a/src/plugins/CacheableExecutorFactory.ts b/src/plugins/CacheableExecutorFactory.ts index f7497e1..a1709ee 100644 --- a/src/plugins/CacheableExecutorFactory.ts +++ b/src/plugins/CacheableExecutorFactory.ts @@ -23,7 +23,7 @@ export class CacheableExecutorFactory implements ExecutorFactory extends DefaultStateEvaluator currentTx: { interactionTxId: string; contractTxId: string }[] ): Promise> { const requestedBlockHeight = executionContext.blockHeight; - logger.verbose(`Requested state block height: ${requestedBlockHeight}`); + logger.debug(`Requested state block height: ${requestedBlockHeight}`); let cachedState: BlockHeightCacheResult> | null = null; @@ -45,7 +45,7 @@ export class CacheableStateEvaluator extends DefaultStateEvaluator cachedState = this.cache.getLessOrEqual(executionContext.contractDefinition.txId, requestedBlockHeight); if (cachedState != null) { - logger.verbose(`Cached state for ${executionContext.contractDefinition.txId} %o`, { + logger.debug(`Cached state for ${executionContext.contractDefinition.txId}`, { block: cachedState.cachedHeight, requestedBlockHeight }); @@ -57,7 +57,7 @@ export class CacheableStateEvaluator extends DefaultStateEvaluator ); } - logger.verbose(`Interactions until [${requestedBlockHeight}] %o`, { + logger.debug(`Interactions until [${requestedBlockHeight}]`, { total: sortedInteractionsUpToBlock.length, cached: sortedInteractionsUpToBlock.length - missingInteractions.length }); @@ -72,7 +72,7 @@ export class CacheableStateEvaluator extends DefaultStateEvaluator if (entry.contractTxId === executionContext.contractDefinition.txId) { const index = missingInteractions.findIndex((tx) => tx.node.id === entry.interactionTxId); if (index !== -1) { - logger.verbose('Inf. Loop fix - removing interaction %o', { + logger.debug('Inf. Loop fix - removing interaction', { contractTxId: entry.contractTxId, interactionTxId: entry.interactionTxId }); @@ -83,7 +83,7 @@ export class CacheableStateEvaluator extends DefaultStateEvaluator // if cache is up-to date - return immediately to speed-up the whole process if (missingInteractions.length === 0 && cachedState) { - logger.verbose(`State up to requested height [${requestedBlockHeight}] fully cached!`); + logger.debug(`State up to requested height [${requestedBlockHeight}] fully cached!`); return cachedState.cachedValue; } } diff --git a/src/plugins/Evolve.ts b/src/plugins/Evolve.ts index edda13e..bd08f36 100644 --- a/src/plugins/Evolve.ts +++ b/src/plugins/Evolve.ts @@ -44,7 +44,7 @@ export class Evolve implements Executi async modify(state: State, executionContext: ExecutionContext): Promise> { const contractTxId = executionContext.contractDefinition.txId; - logger.verbose(`trying to evolve for: ${contractTxId}`); + logger.debug(`trying to evolve for: ${contractTxId}`); const currentSrcTxId = executionContext.contractDefinition.srcTxId; const settings = @@ -60,7 +60,7 @@ export class Evolve implements Executi canEvolve = true; } if (evolve && /[a-z0-9_-]{43}/i.test(evolve) && canEvolve) { - logger.debug('Checking evolve: %o', { + logger.debug('Checking evolve:', { current: currentSrcTxId, evolve }); @@ -68,7 +68,7 @@ export class Evolve implements Executi if (currentSrcTxId !== evolve) { try { // note: that's really nasty IMO - loading original contract definition, but forcing different sourceTxId... - logger.info('Evolving to: %s', evolve); + logger.info(`Evolving to: ${evolve}`); const newContractDefinition = await this.definitionLoader.load(contractTxId, evolve); const newHandler = await this.executorFactory.create(newContractDefinition); @@ -77,7 +77,7 @@ export class Evolve implements Executi contractDefinition: newContractDefinition, handler: newHandler }; - logger.verbose('evolved to: %o', { + logger.debug('evolved to:', { txId: modifiedContext.contractDefinition.txId, srcTxId: modifiedContext.contractDefinition.srcTxId }); diff --git a/yarn.lock b/yarn.lock index dcb17ce..68d8fdd 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5252,7 +5252,7 @@ smartweave@^0.4.41: sentencer "^0.2.1" yargs "^16.2.0" -source-map-support@^0.5.6: +source-map-support@^0.5.19, source-map-support@^0.5.6: version "0.5.19" resolved "https://registry.yarnpkg.com/source-map-support/-/source-map-support-0.5.19.tgz#a98b62f86dcaf4f67399648c085291ab9e8fed61" integrity sha512-Wonm7zOCIJzBGQdB+thsPar0kYuCIzYvxZwlBa87yi/Mdjv7Tip2cyVbLj5o0cFPN4EVkuTwb3GDDyUx2DGnGw== @@ -5748,6 +5748,13 @@ tslib@^2.1.0: resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.3.1.tgz#e8a335add5ceae51aa261d32a490158ef042ef01" integrity sha512-77EbyPPpMz+FRFRuAFlWMtmgUWGe9UOG2Z25NqCwiIjRhOf5iKGuzSe5P2w1laq+FkRy4p+PCuVkJSGkzTEKVw== +tslog@^3.2.1: + version "3.2.1" + resolved "https://registry.yarnpkg.com/tslog/-/tslog-3.2.1.tgz#37df1301211901eb65fd61b9ad7c8554264a7699" + integrity sha512-m8wAtox9wt+h6UDcN1WAQnYwRDOGhMIOp+GAuuufo8T8qKuu726i2W3r47BrA69goVOwgUkp5YwDTvAxTktvPg== + dependencies: + source-map-support "^0.5.19" + tsscmp@1.0.6: version "1.0.6" resolved "https://registry.yarnpkg.com/tsscmp/-/tsscmp-1.0.6.tgz#85b99583ac3589ec4bfef825b5000aa911d605eb"