Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add opt-in logging with verbose flag #253

Open
wants to merge 1 commit into
base: development
Choose a base branch
from

Conversation

vnnkl
Copy link

@vnnkl vnnkl commented Feb 25, 2025

Fixes: #205

Description

This PR refactors the logging functionality in the cashu-ts library to make it opt-in rather than always logging to the console. This improves the developer experience by reducing console noise and giving users control over when logging occurs.

Changes

  • Added a _verbose flag to CashuWallet, CashuMint, and WSConnection classes
  • Implemented private logging methods (log, warn, error) in these classes that only log when verbose mode is enabled
  • Replaced all direct console logging calls with these conditional logging methods
  • Added a global verbose flag in utils.ts with setVerbose function and logWarning function
  • Added verbose flag to the request.ts module with setRequestVerbose function and logError function
  • Updated the CashuMint constructor to set the request verbose flag
  • Updated the ConnectionManager to pass verbose flag to WSConnection instances
  • Added documentation in the README explaining the new verbose option
  • Created comprehensive tests to verify that the verbose flag works correctly across all components

PR Tasks

  • Open PR
  • run npm run test --> no failing unit tests
  • run npm run format

@vnnkl vnnkl changed the base branch from main to development February 25, 2025 16:58
- Enable verbose logging for `CashuMint` and `CashuWallet` classes
- Log various operations like WebSocket connections, quote creation, and validation failures
- Implement internal methods to log messages and warnings when verbose mode is enabled
@vnnkl vnnkl force-pushed the feat/conditionalLogging branch from 10549d7 to 63b7744 Compare February 25, 2025 17:03
Copy link
Collaborator

@gandlafbtc gandlafbtc left a comment

Choose a reason for hiding this comment

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

LGTM

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.

All logs should be conditional
2 participants