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

feat(SDK-2217): add logger with loglevel support #1005

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

JagadeeshKaricherla-branch
Copy link
Contributor

add logger with loglevel support

Pull Request Template

Description

The logger supports different log levels, enabling developers to control the verbosity of log messages based on their requirements.

Logger Implementation

The Web SDK Logger is implemented as part of the Web SDK package. It provides methods for setting the log level and logging messages at various levels of severity.

Log Levels

The following log levels are supported:

  • Verbose: enables full logging - shows/prints all console.info, console.warn, console.error messages
  • Info: shows/prints all console.info, console.warn, console.error messages
  • Warning: shows/prints all console.warn, console.error messages
  • Error: default.shows/prints all console.error messages.
  • None: disables all logging.

Usage

Setting Log Level

set the logLevel method inside init options

branch.init(
    branch_key,
    options: {
        logLevel: 'verbose',
        timeout: 500,
        retry_delay: 400
    },
    callback(err, data),
);

Fixes # (issue) : SDK-2217

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

  • Unit test
  • Integration test

JS Budget Check

Please mention the size in kb before abd after this PR

Files Before After
dist/build.js.
dist/build.min.js

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules
  • I have checked my code and corrected any misspellings

Mentions:

List the person or team responsible for reviewing proposed changes.

cc @BranchMetrics/saas-sdk-devs for visibility.

add logger with loglevel support
* @constructor
*/

Logger = function() {

Choose a reason for hiding this comment

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

Since this is a wrapper over the native console, should we include a tag or namespace like BranchSDK, so that messages emitted from this logger are easily filterable?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

something like BranchSDK::<error message> ?

Copy link
Contributor

github-actions bot commented Apr 16, 2024

Test Results

  1 files  ± 0    1 suites  ±0   1m 2s ⏱️ +5s
177 tests +18  170 ✅ +18  7 💤 ±0  0 ❌ ±0 
180 runs  +18  173 ✅ +18  7 💤 ±0  0 ❌ ±0 

Results for commit c59ade5. ± Comparison against base commit e2b3837.

♻️ This comment has been updated with latest results.

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.

2 participants