Skip to content

fix: replace direct console.* calls with SdkLogger in verifiable-credentials package#1598

Open
devin-ai-integration[bot] wants to merge 1 commit intomainfrom
devin/1771609888-verifiable-credentials-use-sdk-logger
Open

fix: replace direct console.* calls with SdkLogger in verifiable-credentials package#1598
devin-ai-integration[bot] wants to merge 1 commit intomainfrom
devin/1771609888-verifiable-credentials-use-sdk-logger

Conversation

@devin-ai-integration
Copy link
Contributor

Description

Part of a series of PRs to make consoleLogLevel="silent" work across all SDK packages. This PR replaces all ~40 direct console.* calls in @crossmint/client-sdk-verifiable-credentials with SdkLogger instances so they respect the consoleLogLevel setting from CrossmintProvider.

Two patterns are used:

  • src/ layer (crossmintAPI, decryption, presentation, services): Uses a shared credentialsLogger singleton from a new src/logger.ts, initialized via initCredentialsLogger(apiKey) during crossmintAPI.init().
  • src/verifiableCredentialsSDK/ layer (configs, encryption/lit, onchainServices/nft, services/ipfs, presentation/*): Each file creates its own local new SdkLogger() instance.

Important items for review

  • Uninitialized loggers in verifiableCredentialsSDK/: The per-file SdkLogger instances (vcSdkLogger, litLogger, nftLogger, ipfsLogger, nftByLocatorLogger, contractMetadataLogger, collectionsLogger) are never .init()'d. Before init, SdkLogger falls back to raw console.* — meaning these ~20 calls won't actually be silenced by consoleLogLevel. Reviewer should decide if these should instead import the shared credentialsLogger or if a separate init path is needed.
  • Init ordering in crossmintAPI.ts: initCredentialsLogger(apiKey) is called at line 106, but credentialsLogger.warn(...) calls at lines 96 and 101 fire before initialization. These early warnings will use the uninitialized fallback.
  • console.log.info(): All console.log calls were mapped to .info() level, which is a minor semantic change.

Link to Devin run | Requested by @xmint-guille

Test plan

  • Lint passes (pnpm lint)
  • No existing tests were modified; behavior is a mechanical replacement of console calls with logger calls
  • Manual verification: confirm consoleLogLevel="silent" suppresses logs from this package after the credentialsLogger is initialized

Package updates

  • @crossmint/client-sdk-verifiable-credentials: patch (changeset added)

@devin-ai-integration
Copy link
Contributor Author

Original prompt from Guille
we introduced the following change here to supress logs in our sdks:
https://github.com/Crossmint/crossmint-sdk/commit/27194e5751fd4bb3afb190550382760f978d7a20

i've tried this with the following code snippet, and I can still see logs once I'm logged in:
```ts
"use client";

import {
  CrossmintProvider,
  CrossmintAuthProvider,
  CrossmintWalletProvider,
  useAuth,
  useWallet,
} from "@crossmint/client-sdk-react-ui";

function WalletUser() {
  const { login, user } = useAuth();
  const { wallet, status } = useWallet();

  return (
    <div>
      {user == null ? (
        <button onClick={login}>Sign In</button>
      ) : (
        <p>
          Wallet: {wallet?.address} ({status})
        </p>
      )}
    </div>
  );
}

export default function Page() {
  return (
    <CrossmintProvider
      apiKey={process.env.NEXT_PUBLIC_CLIENT_API_KEY ?? ""}
      consoleLogLevel="silent"
    >
      <CrossmintAuthProvider>
        <CrossmintWalletProvider
          createOnLogin={{
            chain: "polygon-amoy",
            signer: { type: "email" },
          }}
        >
          <WalletUser />
        </CrossmintWalletProvider>
      </CrossmintAuthProvider>
    </CrossmintProvider>
  );
}

can you determine the issue and propose a PR in case it's feasible to maintain the silent logs flag in every part of our sdks?

</details>

@changeset-bot
Copy link

changeset-bot bot commented Feb 20, 2026

🦋 Changeset detected

Latest commit: 0033495

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@crossmint/client-sdk-verifiable-credentials Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@devin-ai-integration
Copy link
Contributor Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR that start with 'DevinAI' or '@devin'.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

16 files reviewed, 9 comments

Edit Code Review Agent Settings | Greptile

Comment on lines +96 to 97
credentialsLogger.warn(`API key invalid: ${validationResult.message}`);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Logger used before initialization - this warning will use the uninitialized fallback (raw console.warn) and won't respect consoleLogLevel="silent". Move initCredentialsLogger(apiKey) from line 106 to before line 90 to ensure all logger calls are initialized.

Suggested change
credentialsLogger.warn(`API key invalid: ${validationResult.message}`);
}
initCredentialsLogger(apiKey);
const usageOrigin = this.getOrigin();
if (usageOrigin != null) {
const validationResult = validateAPIKey(apiKey, {
usageOrigin: usageOrigin,
});
if (!validationResult.isValid) {
credentialsLogger.warn(`API key invalid: ${validationResult.message}`);
Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/client/verifiable-credentials/src/crossmintAPI.ts
Line: 96-97

Comment:
Logger used before initialization - this warning will use the uninitialized fallback (raw `console.warn`) and won't respect `consoleLogLevel="silent"`. Move `initCredentialsLogger(apiKey)` from line 106 to before line 90 to ensure all logger calls are initialized.

```suggestion
        initCredentialsLogger(apiKey);
        const usageOrigin = this.getOrigin();
        if (usageOrigin != null) {
            const validationResult = validateAPIKey(apiKey, {
                usageOrigin: usageOrigin,
            });
            if (!validationResult.isValid) {
                credentialsLogger.warn(`API key invalid: ${validationResult.message}`);
```

How can I resolve this? If you propose a fix, please make it concise.

Comment on lines +101 to 104
credentialsLogger.warn(
`Using custom environment: ${config.environment}, you may want to use 'staging' or 'prod' instead`
);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Logger used before initialization - this warning will use the uninitialized fallback and won't respect consoleLogLevel="silent". Will be fixed if you move initCredentialsLogger earlier as suggested above.

Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/client/verifiable-credentials/src/crossmintAPI.ts
Line: 101-104

Comment:
Logger used before initialization - this warning will use the uninitialized fallback and won't respect `consoleLogLevel="silent"`. Will be fixed if you move `initCredentialsLogger` earlier as suggested above.

How can I resolve this? If you propose a fix, please make it concise.


import { type ChainRPCConfig, VCChain } from "./types/chain";

const vcSdkLogger = new SdkLogger();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Uninitialized logger - vcSdkLogger is never .init()'d, so all calls will fall back to raw console.* and won't respect consoleLogLevel="silent". Consider importing and using the shared credentialsLogger from src/logger.ts instead, which gets initialized during crossmintAPI.init().

Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/client/verifiable-credentials/src/verifiableCredentialsSDK/configs.ts
Line: 5

Comment:
Uninitialized logger - `vcSdkLogger` is never `.init()`'d, so all calls will fall back to raw `console.*` and won't respect `consoleLogLevel="silent"`. Consider importing and using the shared `credentialsLogger` from `src/logger.ts` instead, which gets initialized during `crossmintAPI.init()`.

How can I resolve this? If you propose a fix, please make it concise.

import type { EncryptedVerifiableCredential } from "../types";
import { isVerifiableCredential } from "../types/utils";

const litLogger = new SdkLogger();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Uninitialized logger - litLogger is never .init()'d, so all calls will fall back to raw console.* and won't respect consoleLogLevel="silent". Consider importing and using the shared credentialsLogger from src/logger.ts instead.

Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/client/verifiable-credentials/src/verifiableCredentialsSDK/encryption/lit.ts
Line: 10

Comment:
Uninitialized logger - `litLogger` is never `.init()`'d, so all calls will fall back to raw `console.*` and won't respect `consoleLogLevel="silent"`. Consider importing and using the shared `credentialsLogger` from `src/logger.ts` instead.

How can I resolve this? If you propose a fix, please make it concise.

import { abi_ERC_7572 } from "./ABI/ERC7572";
import { getProvider } from "./provider";

const nftLogger = new SdkLogger();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Uninitialized logger - nftLogger is never .init()'d, so all calls will fall back to raw console.* and won't respect consoleLogLevel="silent". Consider importing and using the shared credentialsLogger from src/logger.ts instead.

Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/client/verifiable-credentials/src/verifiableCredentialsSDK/onchainServices/nft.ts
Line: 14

Comment:
Uninitialized logger - `nftLogger` is never `.init()`'d, so all calls will fall back to raw `console.*` and won't respect `consoleLogLevel="silent"`. Consider importing and using the shared `credentialsLogger` from `src/logger.ts` instead.

How can I resolve this? If you propose a fix, please make it concise.

import type { Collection, CredentialsCollection } from "../types/collection";
import { isVerifiableCredentialContractMetadata } from "../types/utils";

const contractMetadataLogger = new SdkLogger();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Uninitialized logger - contractMetadataLogger is never .init()'d, so all calls will fall back to raw console.* and won't respect consoleLogLevel="silent". Consider importing and using the shared credentialsLogger from src/logger.ts instead.

Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/client/verifiable-credentials/src/verifiableCredentialsSDK/presentation/contractMetadata.ts
Line: 9

Comment:
Uninitialized logger - `contractMetadataLogger` is never `.init()`'d, so all calls will fall back to raw `console.*` and won't respect `consoleLogLevel="silent"`. Consider importing and using the shared `credentialsLogger` from `src/logger.ts` instead.

How can I resolve this? If you propose a fix, please make it concise.

import { isVcChain, isVcNft } from "../types/utils";
import { ContractMetadataService } from "./contractMetadata";

const collectionsLogger = new SdkLogger();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Uninitialized logger - collectionsLogger is never .init()'d, so all calls will fall back to raw console.* and won't respect consoleLogLevel="silent". Consider importing and using the shared credentialsLogger from src/logger.ts instead.

Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/client/verifiable-credentials/src/verifiableCredentialsSDK/presentation/getCollections.ts
Line: 10

Comment:
Uninitialized logger - `collectionsLogger` is never `.init()`'d, so all calls will fall back to raw `console.*` and won't respect `consoleLogLevel="silent"`. Consider importing and using the shared `credentialsLogger` from `src/logger.ts` instead.

How can I resolve this? If you propose a fix, please make it concise.

import { isVcChain, isVerifiableCredentialContractMetadata, parseLocator } from "../types/utils";
import { ContractMetadataService } from "./contractMetadata";

const nftByLocatorLogger = new SdkLogger();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Uninitialized logger - nftByLocatorLogger is never .init()'d, so all calls will fall back to raw console.* and won't respect consoleLogLevel="silent". Consider importing and using the shared credentialsLogger from src/logger.ts instead.

Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/client/verifiable-credentials/src/verifiableCredentialsSDK/presentation/nftByLocator.ts
Line: 10

Comment:
Uninitialized logger - `nftByLocatorLogger` is never `.init()`'d, so all calls will fall back to raw `console.*` and won't respect `consoleLogLevel="silent"`. Consider importing and using the shared `credentialsLogger` from `src/logger.ts` instead.

How can I resolve this? If you propose a fix, please make it concise.


import { configManager } from "../configs";

const ipfsLogger = new SdkLogger();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Uninitialized logger - ipfsLogger is never .init()'d, so all calls will fall back to raw console.* and won't respect consoleLogLevel="silent". Consider importing and using the shared credentialsLogger from src/logger.ts instead.

Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/client/verifiable-credentials/src/verifiableCredentialsSDK/services/ipfs.ts
Line: 5

Comment:
Uninitialized logger - `ipfsLogger` is never `.init()`'d, so all calls will fall back to raw `console.*` and won't respect `consoleLogLevel="silent"`. Consider importing and using the shared `credentialsLogger` from `src/logger.ts` instead.

How can I resolve this? If you propose a fix, please make it concise.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant