refactor: replace console statements with logger in extension-base#4928
Open
ruhil6789 wants to merge 2 commits intoKoniverse:masterfrom
Open
refactor: replace console statements with logger in extension-base#4928ruhil6789 wants to merge 2 commits intoKoniverse:masterfrom
ruhil6789 wants to merge 2 commits intoKoniverse:masterfrom
Conversation
- Replaced all console.* statements with logger calls across extension-base - Added logger instances to all service files, API files, and utilities - Fixed TypeScript errors related to missing logger declarations - Test files (.spec.ts) intentionally left unchanged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🔧 Refactor: Replace Console Statements with Structured Logger
Summary
This PR replaces all
console.*statements in theextension-basepackage with a structured logger implementation. This enables better error tracking, debugging capabilities, and integration with monitoring tools like Sentry.Changes Made
Fixes:#4923
Priority 1: Koni API Files
NFT API files (20+ files): All console statements replaced with logger
koni/api/nft/*- All NFT API implementationskoni/api/nft/transfer.ts- NFT transfer utilitieskoni/api/nft/rmrk_nft/*,unique_nft/*,evm_nft/*, etc.Staking APIs: All console statements replaced
koni/api/staking/bonding/*- Bonding utilitieskoni/api/staking/relayChain.ts- Relay chain stakingkoni/api/staking/subsquidStaking.ts- Subsquid integrationOther APIs: Coingecko and Dotsama APIs updated
koni/api/coingecko.ts- Price fetchingkoni/api/dotsama/crowdloan.ts- Crowdloan subscriptionskoni/api/dotsama/domain.ts- Domain resolutionPriority 2: Core Logic Validation
core/logic-validation/request.ts- All validation error logging updatedPriority 3: Utils
utils/metadata.ts- Metadata utilitiesutils/fee/transfer.ts- Fee estimationutils/fetchStaticData.ts- Static data fetchingutils/fetchEvmChainInfo.ts- EVM chain infoutils/eth.ts- Ethereum utilitiesutils/promise.ts- Promise handlersutils/eth/parseTransaction/base.ts- Transaction parsingPriority 4: Other Areas
Base.ts,TransactionHistory.ts,Keyring.tsstorage/index.ts- All storage operationshelpers.ts,subscriptions.tsapi-request-strategy-v2/index.tsconstants/index.tsLogger Implementation Pattern
Each module now uses a dedicated logger instance:cript
import { createLogger } from '@subwallet/extension-base/utils/logger';
const moduleLogger = createLogger('ModuleName');
// Replace console.error → logger.error
// Replace console.warn → logger.warn
// Replace console.log → logger.debug/info
// Replace .catch(console.error) → .catch((e) => logger.error('Context', e))