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: showOutput option & log function #185

Merged
merged 3 commits into from
Aug 21, 2018

Conversation

santoshjoseph99
Copy link
Contributor

Related to #184

Test file:
https://gist.github.com/santoshjoseph99/c796663002b03812cc197fe1f8bb8d38

Note:

  1. I could add a parameter to logFunc to check if the message is a log or an error, since right now I'm just using console.log.
  2. I could also set this up so that logFunc can be passed into PWMetrics as part of the options, so it gives more control to the caller on how to show the messages.

Copy link
Collaborator

@denar90 denar90 left a comment

Choose a reason for hiding this comment

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

@santoshjoseph99 , huge 👍
logFunc is my dream we can have instead of console.log/console.error

I have only one concern about putting it as param when we call one or another method which needs log something

what do you think if we create class Logger, which will be singleton? By default, it will have flag showOutput: true.
Logger will have API aka log with params log(message, type), (type - will be success, error, etc)

setShowOutput can change showOutput flag value which will be used in scope of log to show or not message.

As result we can eliminate something like e.g. prepareData(events, logFunc); for each function and just import class Logger

@santoshjoseph99
Copy link
Contributor Author

@denar90 sounds good. I'll update.

Copy link
Collaborator

@denar90 denar90 left a comment

Choose a reason for hiding this comment

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

lgtm 👍
one nitpick, can you update docs so we can land it?

@santoshjoseph99
Copy link
Contributor Author

@denar90 I'm not sure what you mean by the land on the docs?

Also I'm seeing a failure in CI...should I change the signature of the log function to be:

  log(msg: any, ...args: any[]) {
    if(Logger.options.showOutput){
      console.log(msg, ...args);
    }
  }

?

@denar90
Copy link
Collaborator

denar90 commented Aug 21, 2018

Moving thread here,


lgtm 👍
one nitpick, can you update docs so we can land it?


@denar90 I'm not sure what you mean by the land on the docs?
Also I'm seeing a failure in CI...should I change the signature of the log function to be:

  log(msg: any, ...args: any[]) {
    if(Logger.options.showOutput){
      console.log(msg, ...args);
    }
  }

?


Sorry, for the confusion.
I meant that it will be nice if you can update readme.md about new flag. As result we can publish new version.
And I'm ok with signature of the log function.

Copy link
Collaborator

@denar90 denar90 left a comment

Choose a reason for hiding this comment

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

Thanks a looot 👍

@denar90 denar90 merged commit f4cbe0f into paulirish:master Aug 21, 2018
@denar90 denar90 mentioned this pull request Aug 22, 2018
@denar90
Copy link
Collaborator

denar90 commented Aug 22, 2018

v3.3.0 published to npm 🎉

@santoshjoseph99
Copy link
Contributor Author

🆒

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