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 disableServerLogging option #39

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

Conversation

pushpinder107
Copy link

Addresses #19 by adding disableServerLogging option.

Usage

const logger = Logger({ url: '/test/api/log', disableServerLogging: true });

test/test.js Outdated
@@ -128,4 +128,47 @@ describe('beaver-logger tests', () => {
}
});
});

it('should not send event to server if enableServerLogging is false', () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

if disableServerLogging is true

Copy link
Author

Choose a reason for hiding this comment

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

Fixed

test/test.js Outdated
logEndpoint.expectCalls();
return $logger.flush().then(() => {
try {
logEndpoint.done(); // will throw is not API calls received by logEndpoint
Copy link
Contributor

@mnicpt mnicpt Oct 6, 2020

Choose a reason for hiding this comment

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

// will throw if API calls received by logEndpoint. How will it throw? I'm guessing you are referring to the if check below if the handler was called. If so, this comment is confusing since we //pass in the catch.

Copy link
Author

Choose a reason for hiding this comment

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

https://github.com/krakenjs/sync-browser-mocks/blob/master/README.md#xmlhttprequest

it('should correctly call /api/user', function() {

myListener.expectCalls();

// Run some code which would call the api

myListener.done(); // This will throw if the api was not called

});

I can set a variable in the catch block to indicate that an exception is indeed thrown.

Copy link
Contributor

Choose a reason for hiding this comment

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

👍

Copy link
Author

Choose a reason for hiding this comment

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

Done

Copy link
Contributor

@mnicpt mnicpt left a comment

Choose a reason for hiding this comment

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

Looks great! Thanks, @pushpinder107! 🎉

@TD-4242
Copy link

TD-4242 commented Oct 21, 2022

Can this be done an a per level basis? I would like to avoid sending debug logs to the server side unless they are enabled.

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.

3 participants