Skip to content

feat(util-invariant): Convert to use util-logger under the hood #2418

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

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

lanceherman
Copy link

Description

This PR addresses issue #1488 by converting the util-invariant package to use util-logger under the hood instead of direct console.error calls.

Changes

  • Converted util-invariant to use util-logger for logging
  • Added optional logger level parameter to control logging behavior
  • Maintained backward compatibility (defaults to error level and throwing)
  • Added @onflow/util-logger as a dependency
  • Fixed invalid type check in on-message-from-fcl.js

Implementation Details

  • Default behavior remains the same (throws error) for backward compatibility
  • New optional parameter allows changing logger level (e.g., to warning)
  • When level is set to non-error, it prevents error throwing
  • Fixed type checking issue in message handler

Testing

The changes maintain the existing functionality while adding the ability to:

  • Use util-logger for consistent logging
  • Optionally change log level
  • Prevent error throwing when needed

Fixes #1488

…` and add optional logger level parameter. Update package dependencies to include `@onflow/util-logger`.
@lanceherman lanceherman requested a review from a team as a code owner May 10, 2025 07:59
Copy link

changeset-bot bot commented May 10, 2025

⚠️ No Changeset found

Latest commit: e89c424

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

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

@lanceherman
Copy link
Author

Hey @chasefleming could you review the changes and check if everything's alright. Thanks.

@lanceherman
Copy link
Author

Hi @jribbink, thanks for the review!

The optional loggerLevel parameter was actually one of the specific requirements by @chasefleming in the original issue (#1488). From the issue description:

If syntax is the same, then default to util logger throwing an error
Add another arg that if set lets you change the logger level (e.g. to warning). This would also stop the throwing of the error.

That's why I implemented it this way:

By default (no logger level specified), it behaves exactly as before - throwing errors
The optional parameter allows changing to warning level, which was explicitly requested

lanceherman and others added 2 commits May 26, 2025 21:51
Co-authored-by: Jordan Ribbink <17958158+jribbink@users.noreply.github.com>
@lanceherman
Copy link
Author

hey @jribbink could you please review the changes.

@lanceherman
Copy link
Author

hey @jribbink if you have time, please could you check if everything's alright

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.

util-invariant should use logger under the hood
2 participants